From b3a50d88314ac36ca5ae7bb44d01484a2feae223 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Wed, 26 Jun 2024 21:05:21 +0200 Subject: [PATCH] add test method example and test --- examples/main.go | 21 ++++++++++++++++++++- helm/dagger/main.go | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/main.go b/examples/main.go index 4ab633d..69adbce 100644 --- a/examples/main.go +++ b/examples/main.go @@ -14,6 +14,7 @@ func (m *Examples) All(ctx context.Context) error { p := pool.New().WithErrors().WithContext(ctx) p.Go(m.Version) + p.Go(m.Test) return p.Wait() } @@ -24,7 +25,7 @@ func (m *Examples) Version( ) error { const expected = "0.1.1" - // dagger call version --directory ./mychart/ + // dagger call version --directory ./examples/testdata/mychart/ directory := dag.CurrentModule().Source().Directory("testdata/mychart/") version, err := dag.Helm().Version(ctx, directory) @@ -38,3 +39,21 @@ func (m *Examples) Version( return nil } + + +func (m *Examples) Test( + // method call context + ctx context.Context, +) error { + args := []string{"."} + + // dagger call test --directory ./examples/testdata/mychart/ --args "." + directory := dag.CurrentModule().Source().Directory("testdata/mychart/") + _, err := dag.Helm().Test(ctx, directory, args) + + if err != nil { + return err + } + + return nil +} diff --git a/helm/dagger/main.go b/helm/dagger/main.go index 68d97af..b5a068d 100644 --- a/helm/dagger/main.go +++ b/helm/dagger/main.go @@ -40,7 +40,7 @@ func (p PushOpts) getRepoFqdn() string { // Get and display the version of the Helm Chart located inside the given directory. // -// Example usage: dagger call version --directory ./mychart/ +// Example usage: dagger call version --directory ./examples/testdata/mychart/ func (h *Helm) Version( // method call context ctx context.Context, @@ -146,7 +146,7 @@ func (h *Helm) PackagePush( // Provide the helm chart directory with pointing to it with the `--directory` flag. // Add the directory location with `"."` as `--args` parameter to tell helm unittest where to find the helm chart with the tests. // -// Example usage: dagger call test --directory ./mychart/ --args "." +// Example usage: dagger call test --directory ./examples/testdata/mychart/ --args "." func (h *Helm) Test( // method call context ctx context.Context,