Skip to content

Commit

Permalink
chore: Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed May 19, 2019
1 parent 9f525c9 commit 790b4cd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn_revision_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kn revision describe NAME [flags]
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for describe
-n, --namespace string List the requested object(s) in given namespace.
-o, --output string Output format. One of: json|yaml|name|go-template|go-template-file|templatefile|template|jsonpath|jsonpath-file. (default "yaml")
-o, --output string Output format. One of: json|yaml|name|template|go-template|go-template-file|templatefile|jsonpath|jsonpath-file. (default "yaml")
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
```

Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_service_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kn service get [flags]
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for get
-n, --namespace string List the requested object(s) in given namespace.
-o, --output string Output format. One of: json|yaml|name|template|go-template|go-template-file|templatefile|jsonpath-file|jsonpath.
-o, --output string Output format. One of: json|yaml|name|template|go-template|go-template-file|templatefile|jsonpath|jsonpath-file.
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
```

Expand Down
12 changes: 11 additions & 1 deletion pkg/kn/commands/service_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
serving_lib "github.com/knative/client/pkg/serving"
servingv1alpha1 "github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -69,7 +70,16 @@ func NewServiceCreateCommand(p *KnParams) *cobra.Command {
Namespace: namespace,
},
}
service.Spec.DeprecatedRunLatest = &servingv1alpha1.RunLatestType{}

service.Spec.DeprecatedRunLatest = &servingv1alpha1.RunLatestType{
Configuration: servingv1alpha1.ConfigurationSpec{
DeprecatedRevisionTemplate: &servingv1alpha1.RevisionTemplateSpec{
Spec: servingv1alpha1.RevisionSpec{
DeprecatedContainer: &corev1.Container{},
},
},
},
}

config, err := serving_lib.GetConfiguration(&service)
if err != nil {
Expand Down
30 changes: 27 additions & 3 deletions pkg/kn/commands/service_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ func TestServiceUpdateImage(t *testing.T) {
Namespace: "default",
},
Spec: v1alpha1.ServiceSpec{
DeprecatedRunLatest: &v1alpha1.RunLatestType{},
DeprecatedRunLatest: &v1alpha1.RunLatestType{
Configuration: v1alpha1.ConfigurationSpec{
DeprecatedRevisionTemplate: &v1alpha1.RevisionTemplateSpec{
Spec: v1alpha1.RevisionSpec{
DeprecatedContainer: &corev1.Container{},
},
},
},
},
},
}

Expand Down Expand Up @@ -119,7 +127,15 @@ func TestServiceUpdateEnv(t *testing.T) {
Namespace: "default",
},
Spec: v1alpha1.ServiceSpec{
DeprecatedRunLatest: &v1alpha1.RunLatestType{},
DeprecatedRunLatest: &v1alpha1.RunLatestType{
Configuration: v1alpha1.ConfigurationSpec{
DeprecatedRevisionTemplate: &v1alpha1.RevisionTemplateSpec{
Spec: v1alpha1.RevisionSpec{
DeprecatedContainer: &corev1.Container{},
},
},
},
},
},
}

Expand Down Expand Up @@ -280,7 +296,15 @@ func createMockServiceWithResources(t *testing.T, requestCPU, requestMemory, lim
Namespace: "default",
},
Spec: v1alpha1.ServiceSpec{
DeprecatedRunLatest: &v1alpha1.RunLatestType{},
DeprecatedRunLatest: &v1alpha1.RunLatestType{
Configuration: v1alpha1.ConfigurationSpec{
DeprecatedRevisionTemplate: &v1alpha1.RevisionTemplateSpec{
Spec: v1alpha1.RevisionSpec{
DeprecatedContainer: &corev1.Container{},
},
},
},
},
},
}

Expand Down
18 changes: 14 additions & 4 deletions pkg/serving/config_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

func TestUpdateEnvVarsNew(t *testing.T) {
config := servingv1alpha1.ConfigurationSpec{}
config := getEmptyConfigurationSpec()
env := map[string]string{
"a": "foo",
"b": "bar",
Expand All @@ -42,7 +42,7 @@ func TestUpdateEnvVarsNew(t *testing.T) {
}

func TestUpdateEnvVarsAppend(t *testing.T) {
config := servingv1alpha1.ConfigurationSpec{}
config := getEmptyConfigurationSpec()
config.DeprecatedRevisionTemplate.Spec.DeprecatedContainer.Env = []corev1.EnvVar{
corev1.EnvVar{Name: "a", Value: "foo"}}
env := map[string]string{
Expand All @@ -68,7 +68,7 @@ func TestUpdateEnvVarsAppend(t *testing.T) {
}

func TestUpdateEnvVarsModify(t *testing.T) {
config := servingv1alpha1.ConfigurationSpec{}
config := getEmptyConfigurationSpec()
config.DeprecatedRevisionTemplate.Spec.DeprecatedContainer.Env = []corev1.EnvVar{
corev1.EnvVar{Name: "a", Value: "foo"}}
env := map[string]string{
Expand All @@ -93,7 +93,7 @@ func TestUpdateEnvVarsModify(t *testing.T) {
}

func TestUpdateEnvVarsBoth(t *testing.T) {
config := servingv1alpha1.ConfigurationSpec{}
config := getEmptyConfigurationSpec()
config.DeprecatedRevisionTemplate.Spec.DeprecatedContainer.Env = []corev1.EnvVar{
corev1.EnvVar{Name: "a", Value: "foo"},
corev1.EnvVar{Name: "c", Value: "caroline"}}
Expand All @@ -120,3 +120,13 @@ func TestUpdateEnvVarsBoth(t *testing.T) {
t.Fatalf("Env did not match expected %v found %v", env, found)
}
}

func getEmptyConfigurationSpec() servingv1alpha1.ConfigurationSpec {
return servingv1alpha1.ConfigurationSpec{
DeprecatedRevisionTemplate: &servingv1alpha1.RevisionTemplateSpec{
Spec: servingv1alpha1.RevisionSpec{
DeprecatedContainer: &corev1.Container{},
},
},
}
}

0 comments on commit 790b4cd

Please sign in to comment.