dagger-helm/internal/accept_test/compile_test.go

42 lines
881 B
Go
Raw Normal View History

2023-04-06 22:30:09 +02:00
package accepttest
import (
"context"
"os"
"testing"
"dagger.io/dagger"
daggerhelm "git.front.kjuulh.io/kjuulh/dagger-helm"
"github.com/stretchr/testify/assert"
)
func TestCompile(t *testing.T) {
t.Parallel()
ctx := context.Background()
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
assert.NoError(t, err)
2023-04-07 00:06:38 +02:00
t.Cleanup(func() {
_ = os.RemoveAll("test_data/dist")
})
2023-04-06 22:30:09 +02:00
t.Run("can generate nginx helm chart", func(t *testing.T) {
2023-04-07 00:06:38 +02:00
_ = os.RemoveAll("test_data/dist/nginx")
2023-04-06 22:30:09 +02:00
ctx := context.Background()
2023-04-07 00:06:38 +02:00
helmoutput, err := daggerhelm.Compile(ctx, client, "test_data/nginx", "test_data/nginx.values.yaml")
exported, err := helmoutput.Export(ctx, "test_data/dist")
2023-04-06 22:30:09 +02:00
assert.NoError(t, err)
2023-04-07 00:06:38 +02:00
assert.True(t, exported)
dir, err := os.ReadDir("test_data/dist/nginx/templates")
assert.NoError(t, err)
assert.Equal(t, 2, len(dir))
2023-04-06 22:30:09 +02:00
})
}