-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6efb65
commit 534f258
Showing
2 changed files
with
60 additions
and
1 deletion.
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
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,43 @@ | ||
package spec | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestCreateSpecFromVariables(t *testing.T) { | ||
t.Run("Valid Inputs", func(t *testing.T) { | ||
spec, err := CreateSpecFromVariables("Common-builds", "1.2.0") | ||
|
||
assert.NoError(t, err) | ||
assert.NotNil(t, spec) | ||
assert.Equal(t, "Common-builds/1.2.0", spec.Files[0].Build) | ||
}) | ||
|
||
t.Run("Missing Build Name", func(t *testing.T) { | ||
spec, err := CreateSpecFromVariables("", "1.2.0") | ||
|
||
assert.Error(t, err) | ||
assert.Nil(t, spec) | ||
assert.EqualError(t, err, "build name and build number must be provided") | ||
}) | ||
|
||
t.Run("Missing Build Number", func(t *testing.T) { | ||
spec, err := CreateSpecFromVariables("Common-builds", "") | ||
|
||
// Assert that an error is returned and the spec is nil | ||
assert.Error(t, err) | ||
assert.Nil(t, spec) | ||
assert.EqualError(t, err, "build name and build number must be provided") | ||
}) | ||
|
||
// Test case when both buildName and buildNumber are empty | ||
t.Run("Empty Build Name and Build Number", func(t *testing.T) { | ||
spec, err := CreateSpecFromVariables("", "") | ||
|
||
// Assert that an error is returned and the spec is nil | ||
assert.Error(t, err) | ||
assert.Nil(t, spec) | ||
assert.EqualError(t, err, "build name and build number must be provided") | ||
}) | ||
} |