Files
my-rook-config/pkg/operator/test/spec_test.go
T
Blaine Gardner ca71b7a311 Ceph mgr: Set up config in init container
Progress toward issue #2003.
Includes design from design doc PR #1578

Use init containers to create configuration for Ceph mgrs. There is only
1 init container in this design:
 1. Using the Rook image, call the Rook binary to create Ceph config
files shared with the mgr daemgr container.

Once this init is run, the main mgr daemgr is run. Leaving room to use
the Ceph-versioned image in the future, call `ceph-mgr --foreground ...`
to run the Ceph mgr.

Signed-off-by: Blaine Gardner <blaine.gardner@suse.com>
2018-09-21 13:11:08 -06:00

74 lines
2.7 KiB
Go

/*
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package test
import "testing"
// Test the tests!
// make one expected arg
func oneExp(s ...string) [][]string {
return [][]string{s}
}
// make actual args
func act(s ...string) []string {
return s
}
func TestArgumentsMatchExpected(t *testing.T) {
type args struct {
expectedArgs [][]string
actualArgs []string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"-f ; ok", args{oneExp("-h"), act("-h")}, false},
{"--flag=val ; ok", args{oneExp("--show=all"), act("--show=all")}, false},
{"--flag val ; ok", args{oneExp("--show", "all"), act("--show", "all")}, false},
{"-fval notfound", args{oneExp("-Ohere"), act("-ohere")}, true},
{"--flag val ; no flag", args{oneExp("--debug", "3"), act("--iterations", "3")}, true},
{"--flag val ; no val", args{oneExp("--debug", "3"), act("--debug", "4")}, true},
{"--flag val ; out of order", args{oneExp("-d", "3"), act("3", "-d")}, true},
{"empty expected arg", args{oneExp(""), act("-h")}, true},
{"empty actual", args{oneExp("-h"), act("")}, true},
{"extra actuals", args{oneExp("-h"), act("-h", "-v")}, true},
{"complicated ; ok", args{
[][]string{{"-h"}, {"-vvv"}, {"-d", "3"}, {"--name=kit"}, {"--name", "sammy"}},
[]string{"-h", "-vvv", "-d", "3", "--name=kit", "--name", "sammy"}}, false},
{"complicated ; missing", args{
[][]string{{"-h"}, {"-vvv"}, {"-d", "3"}, {"--name=kit"}, {"--name", "sammy"}},
[]string{"-h", "-vvv", "-d", "3", "--name", "sammy"}}, true},
{"complicated ; extra actuals", args{
[][]string{{"-h"}, {"-vvv"}, {"-d", "3"}, {"--name=kit"}, {"--name", "sammy"}},
[]string{"-h", "-vvv", "--i-am=extra", "-d", "3", "--name", "sammy"}}, true},
{"complicated ; double instance", args{
[][]string{{"-h"}, {"-vvv"}, {"-d", "3"}, {"--name=kit"}, {"--name", "sammy"}},
[]string{"-h", "-vvv", "-vvv", "-d", "3", "--name", "sammy"}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := ArgumentsMatchExpected(tt.args.actualArgs, tt.args.expectedArgs); (err != nil) != tt.wantErr {
t.Errorf("ArgumentsMatchExpected() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}