Skip to content

Commit

Permalink
Added test to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasgun committed Apr 11, 2022
1 parent 711167f commit 1b3bd2a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
28 changes: 28 additions & 0 deletions pkg/kn/commands/service/configuration_edit_flags_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright © 2022 The Knative Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package service

import (
"testing"

"knative.dev/client/pkg/kn/commands"
)

func TestAddCreateFlags(t *testing.T) {
var editFlags ConfigurationEditFlags
knParams := &commands.KnParams{}
cmd, _, _ := commands.CreateTestKnCommand(NewServiceCreateCommand(knParams), knParams)
editFlags.AddCreateFlags(cmd)
}
5 changes: 3 additions & 2 deletions pkg/serving/config_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,14 @@ func UpdateRevisionTemplateAnnotation(template *servingv1.RevisionTemplateSpec,

// UpdateImagePullPolicy updates the pull policy for the given revision template
func UpdateImagePullPolicy(template *servingv1.RevisionTemplateSpec, imagePullPolicy string) error {
if len(template.Spec.Containers) == 0 {
idx := ContainerIndexOfRevisionSpec(&template.Spec)
if idx < 0 {
return fmt.Errorf("no container found in spec")
}
if !isValidPullPolicy(imagePullPolicy) {
return fmt.Errorf("invalid --pull-policy %s. Valid arguments: Always|Never|IfNotPresent", imagePullPolicy)
}
template.Spec.Containers[0].ImagePullPolicy = v1.PullPolicy(imagePullPolicy)
template.Spec.Containers[idx].ImagePullPolicy = v1.PullPolicy(imagePullPolicy)
return nil
}

Expand Down

0 comments on commit 1b3bd2a

Please sign in to comment.