Skip to content

Commit

Permalink
Added first test
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Dec 11, 2019
1 parent 79f0528 commit 2bd5cf6
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 122 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Manage your Knative building blocks:
* [kn revision](kn_revision.md) - Revision command group
* [kn route](kn_route.md) - Route command group
* [kn service](kn_service.md) - Service command group
* [kn source](kn_source.md) - Event Source command group
* [kn source](kn_source.md) - Event source command group
* [kn version](kn_version.md) - Prints the client version

6 changes: 3 additions & 3 deletions docs/cmd/kn_source.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source

Event Source command group
Event source command group

### Synopsis

Event Source command group
Event source command group

```
kn source [flags]
Expand All @@ -28,6 +28,6 @@ kn source [flags]

* [kn](kn.md) - Knative client
* [kn source apiserver](kn_source_apiserver.md) - Kubernetes API Server Event Source command group
* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
* [kn source cronjob](kn_source_cronjob.md) - Cronjob source command group
* [kn source list-types](kn_source_list-types.md) - List available source types

2 changes: 1 addition & 1 deletion docs/cmd/kn_source_apiserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ kn source apiserver [flags]

### SEE ALSO

* [kn source](kn_source.md) - Event Source command group
* [kn source](kn_source.md) - Event source command group
* [kn source apiserver create](kn_source_apiserver_create.md) - Create an ApiServerSource, which watches for Kubernetes events and forwards them to a sink
* [kn source apiserver delete](kn_source_apiserver_delete.md) - Delete an ApiServerSource.

14 changes: 7 additions & 7 deletions docs/cmd/kn_source_cronjob.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source cronjob

CronJob source command group
Cronjob source command group

### Synopsis

CronJob source command group
Cronjob source command group

```
kn source cronjob [flags]
Expand All @@ -26,9 +26,9 @@ kn source cronjob [flags]

### SEE ALSO

* [kn source](kn_source.md) - Event Source command group
* [kn source cronjob create](kn_source_cronjob_create.md) - Create a Crontab scheduler source.
* [kn source cronjob delete](kn_source_cronjob_delete.md) - Delete a CronJob source.
* [kn source cronjob describe](kn_source_cronjob_describe.md) - Describe a CronJob source.
* [kn source cronjob update](kn_source_cronjob_update.md) - Update a Crontab scheduler source.
* [kn source](kn_source.md) - Event source command group
* [kn source cronjob create](kn_source_cronjob_create.md) - Create a Cronjob source.
* [kn source cronjob delete](kn_source_cronjob_delete.md) - Delete a Cronjob source.
* [kn source cronjob describe](kn_source_cronjob_describe.md) - Describe a Cronjob source.
* [kn source cronjob update](kn_source_cronjob_update.md) - Update a Cronjob source.

6 changes: 3 additions & 3 deletions docs/cmd/kn_source_cronjob_create.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source cronjob create

Create a Crontab scheduler source.
Create a Cronjob source.

### Synopsis

Create a Crontab scheduler source.
Create a Cronjob source.

```
kn source cronjob create NAME --schedule SCHEDULE --sink SINK --data DATA [flags]
Expand Down Expand Up @@ -38,5 +38,5 @@ kn source cronjob create NAME --schedule SCHEDULE --sink SINK --data DATA [flags

### SEE ALSO

* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
* [kn source cronjob](kn_source_cronjob.md) - Cronjob source command group

6 changes: 3 additions & 3 deletions docs/cmd/kn_source_cronjob_delete.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source cronjob delete

Delete a CronJob source.
Delete a Cronjob source.

### Synopsis

Delete a CronJob source.
Delete a Cronjob source.

```
kn source cronjob delete NAME [flags]
Expand Down Expand Up @@ -35,5 +35,5 @@ kn source cronjob delete NAME [flags]

### SEE ALSO

* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
* [kn source cronjob](kn_source_cronjob.md) - Cronjob source command group

6 changes: 3 additions & 3 deletions docs/cmd/kn_source_cronjob_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source cronjob describe

Describe a CronJob source.
Describe a Cronjob source.

### Synopsis

Describe a CronJob source.
Describe a Cronjob source.

```
kn source cronjob describe NAME [flags]
Expand Down Expand Up @@ -36,5 +36,5 @@ kn source cronjob describe NAME [flags]

### SEE ALSO

* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
* [kn source cronjob](kn_source_cronjob.md) - Cronjob source command group

6 changes: 3 additions & 3 deletions docs/cmd/kn_source_cronjob_update.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source cronjob update

Update a Crontab scheduler source.
Update a Cronjob source.

### Synopsis

Update a Crontab scheduler source.
Update a Cronjob source.

```
kn source cronjob update NAME --schedule SCHEDULE --sink SERVICE --data DATA [flags]
Expand Down Expand Up @@ -38,5 +38,5 @@ kn source cronjob update NAME --schedule SCHEDULE --sink SERVICE --data DATA [fl

### SEE ALSO

* [kn source cronjob](kn_source_cronjob.md) - CronJob source command group
* [kn source cronjob](kn_source_cronjob.md) - Cronjob source command group

24 changes: 12 additions & 12 deletions pkg/kn/commands/service/create_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
func TestServiceCreateImageMock(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand All @@ -59,7 +59,7 @@ func TestServiceCreateImageMock(t *testing.T) {
}

func TestServiceCreateEnvMock(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand All @@ -85,7 +85,7 @@ func TestServiceCreateEnvMock(t *testing.T) {
}

func TestServiceCreateLabel(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestServiceCreateLabel(t *testing.T) {
}

func TestServiceCreateWithEnvFromConfigMap(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestServiceCreateWithEnvFromConfigMap(t *testing.T) {
}

func TestServiceCreateWithEnvFromConfigMapRemoval(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand All @@ -164,7 +164,7 @@ func TestServiceCreateWithEnvFromConfigMapRemoval(t *testing.T) {
}

func TestServiceCreateWithEnvFromEmptyRemoval(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand All @@ -182,7 +182,7 @@ func TestServiceCreateWithEnvFromEmptyRemoval(t *testing.T) {
}

func TestServiceCreateWithEnvFromSecret(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestServiceCreateWithEnvFromSecret(t *testing.T) {
}

func TestServiceCreateWithEnvFromSecretRemoval(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand All @@ -232,7 +232,7 @@ func TestServiceCreateWithEnvFromSecretRemoval(t *testing.T) {
}

func TestServiceCreateWithVolumeAndMountConfigMap(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestServiceCreateWithVolumeAndMountConfigMap(t *testing.T) {
}

func TestServiceCreateWithMountConfigMap(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestServiceCreateWithMountConfigMap(t *testing.T) {
}

func TestServiceCreateWithVolumeAndMountSecret(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestServiceCreateWithVolumeAndMountSecret(t *testing.T) {
}

func TestServiceCreateWithMountSecret(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(v1alpha1.Resource("service"), "foo"))
Expand Down
6 changes: 3 additions & 3 deletions pkg/kn/commands/service/delete_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func TestServiceDeleteMock(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand All @@ -42,7 +42,7 @@ func TestServiceDeleteMock(t *testing.T) {

func TestMultipleServiceDeleteMock(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand All @@ -60,7 +60,7 @@ func TestMultipleServiceDeleteMock(t *testing.T) {

func TestServiceDeleteNoSvcNameMock(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down
26 changes: 13 additions & 13 deletions pkg/kn/commands/service/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
func TestServiceDescribeBasic(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestServiceDescribeBasic(t *testing.T) {
}

func TestServiceDescribeSad(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()

expectedService := createTestService("foo", []string{"rev1"}, goodConditions())
Expand All @@ -98,7 +98,7 @@ func TestServiceDescribeSad(t *testing.T) {
func TestServiceDescribeLatest(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()

expectedService := createTestService("foo", []string{"rev1"}, goodConditions())
Expand All @@ -121,7 +121,7 @@ func TestServiceDescribeLatest(t *testing.T) {
func TestServiceDescribeLatestNotInTraffic(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestServiceDescribeLatestNotInTraffic(t *testing.T) {
func TestServiceDescribeEachNamedOnce(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestServiceDescribeEachNamedOnce(t *testing.T) {

func TestServiceDescribeLatestAndCurrentBothHaveTrafficEntries(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestServiceDescribeLatestAndCurrentBothHaveTrafficEntries(t *testing.T) {

func TestServiceDescribeLatestCreatedIsBroken(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestServiceDescribeScaling(t *testing.T) {
{"", "", "20", "30", ""},
} {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestServiceDescribeResources(t *testing.T) {
{"10Mi", "", "100m", "", "10Mi", "100m"},
} {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestServiceDescribeResources(t *testing.T) {

func TestServiceDescribeUserImageVsImage(t *testing.T) {
// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestServiceDescribeUserImageVsImage(t *testing.T) {
func TestServiceDescribeVerbose(t *testing.T) {

// New mock client
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down Expand Up @@ -465,7 +465,7 @@ func TestServiceDescribeVerbose(t *testing.T) {
}

func TestServiceDescribeWithWrongArguments(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)
_, err := executeServiceCommand(client, "describe")
assert.ErrorContains(t, err, "no", "service", "provided")

Expand All @@ -474,7 +474,7 @@ func TestServiceDescribeWithWrongArguments(t *testing.T) {
}

func TestServiceDescribeMachineReadable(t *testing.T) {
client := knclient.NewMockKnClient(t)
client := knclient.NewMockKnServiceClient(t)

// Recording:
r := client.Recorder()
Expand Down
Loading

0 comments on commit 2bd5cf6

Please sign in to comment.