コード例 #1
0
ファイル: fleetctl_test.go プロジェクト: pulcy/j2
func newFakeRegistryForCheckVersion(v string) registry.ClusterRegistry {
	sv, err := semver.NewVersion(v)
	if err != nil {
		panic(err)
	}

	return registry.NewFakeClusterRegistry(sv, 0)
}
コード例 #2
0
ファイル: engine_test.go プロジェクト: ericcapricorn/fleet
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)
		}
	}
}