-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RaftechNL/first-unit-tests
adds(tests): unit tests
- Loading branch information
Showing
9 changed files
with
123 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
go-yaml-merger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ builds: | |
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
- arm64 | ||
binary: ym | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// file: main_test.go | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMergeYAML_TwoFiles(t *testing.T) { | ||
result, err := MergeYAML("tests/test1.yaml", "tests/test2.yaml") | ||
assert.NoError(t, err) | ||
assert.Equal(t, strings.TrimSpace(` | ||
modules: | ||
my_module: | ||
providerAliasRef: my_provider2 | ||
source: github.com/example/module | ||
version: v1.6.0 | ||
my_module2: | ||
providerAliasRef: my_provider2 | ||
source: github.com/example/module | ||
version: v1.6.0 | ||
my_module3: | ||
providerAliasRef: my_provider2 | ||
source: github.com/example/module | ||
version: v1.6.0 | ||
providers: | ||
my_provider: | ||
auth: | ||
ssh_key: ssh:key:2312312 | ||
providerType: github | ||
`), strings.TrimSpace(string(result))) | ||
} | ||
|
||
func TestMergeYAML_MissingFile(t *testing.T) { | ||
result, err := MergeYAML("tests/test1.yaml", "tests/test3.yaml") | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "no such file or directory") | ||
assert.Equal(t, "", string(result)) | ||
} | ||
|
||
func TestMergeYAML_InvalidYAML(t *testing.T) { | ||
result, err := MergeYAML("tests/test1.yaml", "tests/invalid.yaml") | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "failed to unmarshal data from file") | ||
assert.Equal(t, "", string(result)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
foo: bar | ||
{{ invalid yaml }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
providers: | ||
my_provider: | ||
providerType: github | ||
auth: | ||
ssh_key: "ssh:key:2312312" | ||
modules: | ||
my_module: | ||
source: "github.com/example/module" | ||
version: "v1.0.0" | ||
providerAliasRef: "my_provider2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
modules: | ||
my_module: | ||
source: "github.com/example/module" | ||
version: "v1.6.0" | ||
providerAliasRef: "my_provider2" | ||
my_module2: | ||
source: "github.com/example/module" | ||
version: "v1.6.0" | ||
providerAliasRef: "my_provider2" | ||
my_module3: | ||
source: "github.com/example/module" | ||
version: "v1.6.0" | ||
providerAliasRef: "my_provider2" |