Skip to content

Commit

Permalink
test: updated builder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Oct 16, 2024
1 parent bd43891 commit bed63e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sg/internal/source/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,32 @@ import (
func Test_SourceBuilder_FromPath(t *testing.T) {
sources, err := FromPath([]string{"./testdata/sample"}).Complete()
assert.NoError(t, err)
assert.Len(t, sources, 2)
assert.Len(t, sources, 3)
}

func Test_SourceBuilder_ContextRoot(t *testing.T) {
t.Run("empty context root", func(t *testing.T) {
sources, err := FromPath([]string{"./testdata/sample"}).ContextRoot("").Complete()
assert.NoError(t, err)
assert.Len(t, sources, 2)
assert.Len(t, sources, 3)
})

t.Run("relative context root", func(t *testing.T) {
sources, err := FromPath([]string{"./testdata/sample"}).ContextRoot("./testdata").Complete()
assert.NoError(t, err)
assert.Len(t, sources, 2)
assert.Len(t, sources, 3)
assert.Equal(t, "sample/deployment+service.yaml", sources[0].Name())
assert.Equal(t, "sample/service.yaml", sources[1].Name())
assert.Equal(t, "sample/template.json", sources[2].Name())
})

t.Run("relative context root nested", func(t *testing.T) {
sources, err := FromPath([]string{"./testdata/sample"}).ContextRoot("./testdata/sample").Complete()
assert.NoError(t, err)
assert.Len(t, sources, 2)
assert.Len(t, sources, 3)
assert.Equal(t, "deployment+service.yaml", sources[0].Name())
assert.Equal(t, "service.yaml", sources[1].Name())
assert.Equal(t, "template.json", sources[2].Name())
})

t.Run("non-relative context root", func(t *testing.T) {
Expand Down

0 comments on commit bed63e5

Please sign in to comment.