Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Merge 8fec895 into 1fc220b
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ authored Oct 10, 2019
2 parents 1fc220b + 8fec895 commit 517cec7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
13 changes: 13 additions & 0 deletions pkg/engine/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ func (suite *FactoryTestSuite) TestCreate_Ruby() {
require.NotNil(suite.T(), testEngine)
}

func (suite *FactoryTestSuite) TestCreate_Generic() {
//setup
suite.Config.EXPECT().SetDefault(gomock.Any(), gomock.Any()).MinTimes(1)

//test
testEngine, cerr := engine.Create("generic", suite.PipelineData, suite.Config, suite.Scm)

//assert
require.NoError(suite.T(), cerr)
require.NotNil(suite.T(), testEngine)
}


// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestFactoryTestSuite(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ func (str MgrAssembleError) Error() string {
return fmt.Sprintf("MgrAssembleError: %q", string(str))
}

// Raised when the Mgr is not recognized
type MgrUnspecifiedError string

func (str MgrUnspecifiedError) Error() string {
return fmt.Sprintf("MgrUnspecifiedError: %q", string(str))
}

// Raised when credentials required to upload/deploy new package are missing.
type MgrDistCredentialsMissing string

Expand Down
7 changes: 6 additions & 1 deletion pkg/mgr/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func Create(mgrType string, pipelineData *pipeline.Data, config config.Interface
func Detect(packageType string, pipelineData *pipeline.Data, config config.Interface, client *http.Client) (Interface, error) {

var mgrType string
mgrType = "unknown"

switch packageType {
//chef dependency managers
Expand Down Expand Up @@ -100,8 +101,12 @@ func Detect(packageType string, pipelineData *pipeline.Data, config config.Inter
mgrType = "bundler"
}

//empty/generic package manager. Noop.
case "generic":
mgrType = "generic"

default:
return nil, errors.ScmUnspecifiedError(fmt.Sprintf("Unknown %s Packager Manager Type: %s", packageType, mgrType))
return nil, errors.MgrUnspecifiedError(fmt.Sprintf("Unknown Package Manager for Package Type (%s): %s", packageType, mgrType))
}

return Create(mgrType, pipelineData, config, client )
Expand Down
10 changes: 5 additions & 5 deletions pkg/utils/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestGitCheckout(t *testing.T) {
require.NoError(t, cerr)

//test
ferr := utils.GitCheckout(clonePath, "branch_test")
ferr := utils.GitCheckout(clonePath, "do_not_delete_capsulecd_test_branch")

//assert
require.NoError(t, ferr)
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestGitCommit(t *testing.T) {
defer deleteTestRepo(dirPath)
clonePath, cerr := utils.GitClone(dirPath, "commit_to_npm_analogj_test", "https://github.com/AnalogJ/npm_analogj_test.git")
require.NoError(t, cerr)
ferr := utils.GitCheckout(clonePath, "branch_test")
ferr := utils.GitCheckout(clonePath, "do_not_delete_capsulecd_test_branch")
require.NoError(t, ferr)
signature := utils.GitSignature("CapsuleCD", "CapsuleCD@users.noreply.github.com")

Expand Down Expand Up @@ -181,7 +181,7 @@ func TestGitTag(t *testing.T) {
defer deleteTestRepo(dirPath)
clonePath, cerr := utils.GitClone(dirPath, "add_tag_npm_analogj_test", "https://github.com/AnalogJ/npm_analogj_test.git")
require.NoError(t, cerr)
ferr := utils.GitCheckout(clonePath, "branch_test")
ferr := utils.GitCheckout(clonePath, "do_not_delete_capsulecd_test_branch")
require.NoError(t, ferr)
signature := utils.GitSignature("CapsuleCD", "CapsuleCD@users.noreply.github.com")

Expand Down Expand Up @@ -223,7 +223,7 @@ func TestGitPush(t *testing.T) {
clonePath, cerr := utils.GitClone(dirPath, "push_npm_analogj_test", "https://access_token_here:@github.com/AnalogJ/npm_analogj_test.git")
require.NoError(t, cerr)

ferr := utils.GitCheckout(clonePath, "branch_test")
ferr := utils.GitCheckout(clonePath, "do_not_delete_capsulecd_test_branch")
require.NoError(t, ferr)
signature := utils.GitSignature("CapsuleCD", "CapsuleCD@users.noreply.github.com")

Expand All @@ -235,7 +235,7 @@ func TestGitPush(t *testing.T) {
gcerr := utils.GitCommit(clonePath, "Added New File", signature)
require.NoError(t, gcerr)

perr := utils.GitPush(clonePath, "branch_test", "branch_test", "v1.0.0")
perr := utils.GitPush(clonePath, "do_not_delete_capsulecd_test_branch", "do_not_delete_capsulecd_test_branch", "v1.0.0")
require.NoError(t, perr)

}
Expand Down

0 comments on commit 517cec7

Please sign in to comment.