-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM probe unit test epam/hub-extensions#36
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package lifecycle | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/epam/hubctl/cmd/hub/manifest" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProbeARM(t *testing.T) { | ||
requiresFoo := manifest.Manifest{ | ||
Requires: []string{"foo"}, | ||
} | ||
|
||
found, err := probeImplementation("./foo", "deploy", &requiresFoo) | ||
if err != nil { | ||
assert.Errorf(t, err, "When 'foo' in requires is not a well known, should not find implementation and fail with error", err) | ||
} | ||
assert.Falsef(t, found, "When 'foo' in requires is not a well known, should not find implementation and fail with error") | ||
|
||
requiresARM := manifest.Manifest{ | ||
Requires: []string{"arm"}, | ||
} | ||
found, err = probeImplementation("./foo", "deploy", &requiresARM) | ||
if err != nil { | ||
assert.NoErrorf(t, err, "When 'arm' in component requires, it should resolve to implementation %v", err) | ||
} | ||
assert.Truef(t, found, "When 'arm' in component requires, it should resolve to implementation") | ||
} | ||
|
||
// ARM extension should be called when component requires 'arm' in the manifest | ||
func TestFindARMImplementation(t *testing.T) { | ||
requiresARM := manifest.Manifest{ | ||
Requires: []string{"arm"}, | ||
} | ||
extension, err := findImplementation("./foo", "deploy", &requiresARM) | ||
if err != nil { | ||
assert.Fail(t, "When 'arm' in component requires, it should resolve to extension. Error is not expected here") | ||
} | ||
assert.NotNil(t, extension, "When 'arm' in component requires, it should resolve to the extension") | ||
|
||
assert.Contains(t, extension.Path, "/hub-component-arm", "ARM extension should be returned") | ||
assert.FileExists(t, extension.Path, "ARM should extension should be found in the file system") | ||
} |