Skip to content

Commit

Permalink
ARM probe unit test epam/hub-extensions#36
Browse files Browse the repository at this point in the history
  • Loading branch information
akranga committed Jan 30, 2023
1 parent 0f967d6 commit be5a405
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions cmd/hub/lifecycle/probe_test.go
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")
}

0 comments on commit be5a405

Please sign in to comment.