Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
ksonnet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ijaz Ahmad
ksonnet
Commits
652d7c4c
Unverified
Commit
652d7c4c
authored
6 years ago
by
bryanl
Browse files
Options
Downloads
Patches
Plain Diff
removing need for github access for registry tests
Signed-off-by:
bryanl
<
bryanliles@gmail.com
>
parent
6f63da73
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
actions/init.go
+19
-13
19 additions, 13 deletions
actions/init.go
actions/init_test.go
+9
-0
9 additions, 0 deletions
actions/init_test.go
pkg/registry/manager_test.go
+23
-11
23 additions, 11 deletions
pkg/registry/manager_test.go
with
51 additions
and
24 deletions
actions/init.go
+
19
−
13
View file @
652d7c4c
...
...
@@ -38,6 +38,7 @@ func RunInit(fs afero.Fs, name, rootPath, k8sSpecFlag, serverURI, namespace stri
}
type
appInitFn
func
(
fs
afero
.
Fs
,
name
,
rootPath
,
k8sSpecFlag
,
serverURI
,
namespace
string
,
registries
[]
registry
.
Registry
)
error
type
initIncubatorFn
func
()
(
registry
.
Registry
,
error
)
// Init creates a component namespace
type
Init
struct
{
...
...
@@ -48,19 +49,21 @@ type Init struct {
serverURI
string
namespace
string
appInitFn
appInitFn
appInitFn
appInitFn
initIncubatorFn
initIncubatorFn
}
// NewInit creates an instance of Init.
func
NewInit
(
fs
afero
.
Fs
,
name
,
rootPath
,
k8sSpecFlag
,
serverURI
,
namespace
string
)
(
*
Init
,
error
)
{
i
:=
&
Init
{
fs
:
fs
,
name
:
name
,
rootPath
:
rootPath
,
k8sSpecFlag
:
k8sSpecFlag
,
serverURI
:
serverURI
,
namespace
:
namespace
,
appInitFn
:
appinit
.
Init
,
fs
:
fs
,
name
:
name
,
rootPath
:
rootPath
,
k8sSpecFlag
:
k8sSpecFlag
,
serverURI
:
serverURI
,
namespace
:
namespace
,
appInitFn
:
appinit
.
Init
,
initIncubatorFn
:
initIncubator
,
}
return
i
,
nil
...
...
@@ -68,11 +71,7 @@ func NewInit(fs afero.Fs, name, rootPath, k8sSpecFlag, serverURI, namespace stri
// Run runs that ns create action.
func
(
i
*
Init
)
Run
()
error
{
gh
,
err
:=
registry
.
NewGitHub
(
&
app
.
RegistryRefSpec
{
Name
:
"incubator"
,
Protocol
:
registry
.
ProtocolGitHub
,
URI
:
defaultIncubatorURI
,
})
gh
,
err
:=
i
.
initIncubatorFn
()
if
err
!=
nil
{
return
err
}
...
...
@@ -88,5 +87,12 @@ func (i *Init) Run() error {
i
.
namespace
,
registries
,
)
}
func
initIncubator
()
(
registry
.
Registry
,
error
)
{
return
registry
.
NewGitHub
(
&
app
.
RegistryRefSpec
{
Name
:
"incubator"
,
Protocol
:
registry
.
ProtocolGitHub
,
URI
:
defaultIncubatorURI
,
})
}
This diff is collapsed.
Click to expand it.
actions/init_test.go
+
9
−
0
View file @
652d7c4c
...
...
@@ -20,6 +20,7 @@ import (
amocks
"github.com/ksonnet/ksonnet/metadata/app/mocks"
"github.com/ksonnet/ksonnet/pkg/registry"
rmocks
"github.com/ksonnet/ksonnet/pkg/registry/mocks"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
...
...
@@ -55,6 +56,14 @@ func TestInit(t *testing.T) {
return
nil
}
a
.
initIncubatorFn
=
func
()
(
registry
.
Registry
,
error
)
{
r
:=
&
rmocks
.
Registry
{}
r
.
On
(
"Protocol"
)
.
Return
(
"github"
)
r
.
On
(
"URI"
)
.
Return
(
"github.com/ksonnet/parts/tree/master/incubator"
)
r
.
On
(
"Name"
)
.
Return
(
"incubator"
)
return
r
,
nil
}
err
=
a
.
Run
()
require
.
NoError
(
t
,
err
)
})
...
...
This diff is collapsed.
Click to expand it.
pkg/registry/manager_test.go
+
23
−
11
View file @
652d7c4c
...
...
@@ -60,18 +60,30 @@ func Test_Package(t *testing.T) {
}
func
Test_List
(
t
*
testing
.
T
)
{
specs
:=
app
.
RegistryRefSpecs
{
"incubator"
:
&
app
.
RegistryRefSpec
{
Protocol
:
ProtocolGitHub
,
URI
:
"github.com/ksonnet/parts/tree/master/incubator"
,
},
}
withApp
(
t
,
func
(
a
*
mocks
.
App
,
fs
afero
.
Fs
)
{
c
:=
&
ghmocks
.
GitHub
{}
c
.
On
(
"CommitSHA1"
,
mock
.
Anything
,
github
.
Repo
{
Org
:
"ksonnet"
,
Repo
:
"parts"
},
mock
.
AnythingOfType
(
"string"
))
.
Return
(
"12345"
,
nil
)
appMock
:=
&
mocks
.
App
{}
appMock
.
On
(
"Registries"
)
.
Return
(
specs
,
nil
)
ghcOpt
:=
GitHubClient
(
c
)
githubFactory
=
func
(
spec
*
app
.
RegistryRefSpec
)
(
*
GitHub
,
error
)
{
return
NewGitHub
(
spec
,
ghcOpt
)
}
registries
,
err
:=
List
(
appMock
)
require
.
NoError
(
t
,
err
)
specs
:=
app
.
RegistryRefSpecs
{
"incubator"
:
&
app
.
RegistryRefSpec
{
Protocol
:
ProtocolGitHub
,
URI
:
"github.com/ksonnet/parts/tree/master/incubator"
,
},
}
require
.
Len
(
t
,
registries
,
1
)
appMock
:=
&
mocks
.
App
{}
appMock
.
On
(
"Registries"
)
.
Return
(
specs
,
nil
)
registries
,
err
:=
List
(
appMock
)
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
registries
,
1
)
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment