mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-06 19:07:39 +02:00
* eat: adding ability for for charts to be pulled without HTTPS accomplished by: - Adding PlainHttp attribute to RepositorySpec., HelmDefault, ReleaseSpec - Adding UnitTests for getOCIChart Flags. - Adding funciton and unitTests for getChartDownload - Changing and refactoring how Flags are added to getOCIChart. Resolves #1224 Signed-off-by: Peter Halliday <peter.halliday@servicenow.com> * Pass PlainHttp to OCI repo options, fix unit test Signed-off-by: Pascal Rivard <privard@rbbn.com> * Fix doc Signed-off-by: Pascal Rivard <privard@rbbn.com> * Use repository fields in non-OCI chart download options Signed-off-by: Pascal Rivard <privard@rbbn.com> * Update hashes in TestGenerateID Signed-off-by: Pascal Rivard <privard@rbbn.com> * Make sure repo exists when using its options Signed-off-by: Pascal Rivard <privard@rbbn.com> * Do not add TLS options if PlainHttp is set, adapt unit tests Signed-off-by: Pascal Rivard <privard@rbbn.com> * Fix doc Signed-off-by: Pascal Rivard <privard@rbbn.com> * Remove 'else if' from appendChartDownloadFlags Signed-off-by: Pascal Rivard <privard@rbbn.com> --------- Signed-off-by: Peter Halliday <peter.halliday@servicenow.com> Signed-off-by: Pascal Rivard <privard@rbbn.com> Co-authored-by: Peter Halliday <peter.halliday@servicenow.com> Co-authored-by: Pascal Rivard <privard@rbbn.com>
82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
package state
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestGenerateID(t *testing.T) {
|
|
type testcase struct {
|
|
subject string
|
|
release ReleaseSpec
|
|
data any
|
|
want string
|
|
}
|
|
|
|
ids := map[string]int{}
|
|
|
|
run := func(tc testcase) {
|
|
t.Helper()
|
|
|
|
t.Run(tc.subject, func(t *testing.T) {
|
|
t.Helper()
|
|
|
|
got, err := generateValuesID(&tc.release, tc.data)
|
|
if err != nil {
|
|
t.Fatalf("uenxpected error: %v", err)
|
|
}
|
|
|
|
if d := cmp.Diff(tc.want, got); d != "" {
|
|
t.Fatalf("unexpected result: want (-), got (+):\n%s", d)
|
|
}
|
|
|
|
ids[got]++
|
|
})
|
|
}
|
|
|
|
run(testcase{
|
|
subject: "baseline",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
want: "foo-values-867bdd68d",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different bytes content",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
data: []byte(`{"k":"v"}`),
|
|
want: "foo-values-55d7dc5f87",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different map content",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
data: map[string]any{"k": "v"},
|
|
want: "foo-values-58bdcf44f7",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different chart",
|
|
release: ReleaseSpec{Name: "foo", Chart: "stable/envoy"},
|
|
want: "foo-values-67dcddd85",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different name",
|
|
release: ReleaseSpec{Name: "bar", Chart: "incubator/raw"},
|
|
want: "bar-values-6dd4989f97",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "specific ns",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw", Namespace: "myns"},
|
|
want: "myns-foo-values-755d4487dc",
|
|
})
|
|
|
|
for id, n := range ids {
|
|
if n > 1 {
|
|
t.Fatalf("too many occurrences of %s: %d", id, n)
|
|
}
|
|
}
|
|
}
|