Пример #1
0
func newFakeRegistryForCheckVersion(v string) registry.ClusterRegistry {
	sv, err := semver.NewVersion(v)
	if err != nil {
		panic(err)
	}

	return registry.NewFakeClusterRegistry(sv, 0)
}
Пример #2
0
func TestEnsureEngineVersionMatch(t *testing.T) {
	tests := []struct {
		current int
		target  int

		wantMatch   bool
		wantVersion int
	}{
		{
			current:     0,
			target:      1,
			wantMatch:   true,
			wantVersion: 1,
		},
		{
			current:     1,
			target:      1,
			wantMatch:   true,
			wantVersion: 1,
		},

		{
			current:     2,
			target:      1,
			wantMatch:   false,
			wantVersion: 2,
		},
	}

	for i, tt := range tests {
		cReg := registry.NewFakeClusterRegistry(nil, tt.current)
		gotMatch := ensureEngineVersionMatch(cReg, tt.target)
		if tt.wantMatch != gotMatch {
			t.Errorf("case %d: ensureEngineVersionMatch result incorrect: want=%t got=%t", i, tt.wantMatch, gotMatch)
		}

		gotVersion, _ := cReg.EngineVersion()
		if tt.wantVersion != gotVersion {
			t.Errorf("case %d: resulting envine version incorrect: want=%d got=%d", i, tt.wantVersion, gotVersion)
		}
	}
}