MCPcopy Create free account
hub / github.com/conforma/cli / TestComputeInfo

Function TestComputeInfo

internal/version/version_test.go:49–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestComputeInfo(t *testing.T) {
50 readBuildInfo = func() (info *dbg.BuildInfo, ok bool) {
51 return &dbg.BuildInfo{
52 Settings: []dbg.BuildSetting{
53 {
54 Key: "vcs.revision",
55 Value: "abc",
56 },
57 {
58 Key: "vcs.time",
59 Value: "2009-11-10T23:00:00Z",
60 },
61 },
62 Deps: []*dbg.Module{
63 {Path: "github.com/conforma/crds/api", Version: "v1"},
64 {Path: "github.com/open-policy-agent/opa", Version: "v2"},
65 {Path: "github.com/open-policy-agent/conftest", Version: "v3"},
66 {Path: "github.com/sigstore/cosign/v3", Version: "v4"},
67 {Path: "github.com/sigstore/sigstore", Version: "v5"},
68 {Path: "github.com/sigstore/rekor", Version: "v6"},
69 {Path: "github.com/tektoncd/pipeline", Version: "v7"},
70 {Path: "k8s.io/api", Version: "v8"},
71 },
72 }, true
73 }
74 Version = "v1"
75 t.Cleanup(func() { readBuildInfo = dbg.ReadBuildInfo; Version = "" })
76
77 vi, err := ComputeInfo()
78 assert.NoError(t, err)
79 assert.Equal(t, &VersionInfo{
80 Version: "v1",
81 Commit: "abc",
82 ChangedOn: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
83 Components: []ComponentInfo{
84 {Name: "ECC", Version: "v1"},
85 {Name: "OPA", Version: "v2"},
86 {Name: "Conftest", Version: "v3"},
87 {Name: "Cosign", Version: "v4"},
88 {Name: "Sigstore", Version: "v5"},
89 {Name: "Rekor", Version: "v6"},
90 {Name: "Tekton Pipeline", Version: "v7"},
91 {Name: "Kubernetes Client", Version: "v8"},
92 },
93 }, vi)
94}
95
96func TestDependencyVersion(t *testing.T) {
97 assert.Equal(t, ComponentInfo{Name: "dep", Version: "N/A"}, dependencyVersion("dep", "path", nil))

Callers

nothing calls this directly

Calls 2

ComputeInfoFunction · 0.85
CleanupMethod · 0.80

Tested by

no test coverage detected