Skip to content

Commit

Permalink
Fixes for test
Browse files Browse the repository at this point in the history
  • Loading branch information
johnugeorge committed Aug 7, 2019
1 parent 414b920 commit 29dae72
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
9 changes: 6 additions & 3 deletions pkg/common/util/v1/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (

const (
LabelGroupName = "group-name"
LabelTFJobName = "job-name"
JobNameLabel = "job-name"
// Deprecated label. Has to be removed later
DeprecatedLabelTFJobName = "tf-job-name"
)

var (
Expand All @@ -42,8 +44,9 @@ var (

func GenLabels(jobName string) map[string]string {
return map[string]string{
LabelGroupName: GroupName,
LabelTFJobName: strings.Replace(jobName, "/", "-", -1),
LabelGroupName: GroupName,
JobNameLabel: strings.Replace(jobName, "/", "-", -1),
DeprecatedLabelTFJobName: strings.Replace(jobName, "/", "-", -1),
}
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/common/util/v1beta2/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
)

const (
LabelGroupName = "group-name"
LabelTFJobName = "job-name"
LabelGroupName = "group-name"
JobNameLabel = "job-name"
DeprecatedLabelTFJobName = "tf-job-name"
)

var (
Expand All @@ -42,8 +43,9 @@ var (

func GenLabels(jobName string) map[string]string {
return map[string]string{
LabelGroupName: GroupName,
LabelTFJobName: strings.Replace(jobName, "/", "-", -1),
LabelGroupName: GroupName,
JobNameLabel: strings.Replace(jobName, "/", "-", -1),
DeprecatedLabelTFJobName: strings.Replace(jobName, "/", "-", -1),
}
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/controller.v1/tensorflow/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"k8s.io/apimachinery/pkg/types"

tfv1 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
"github.com/kubeflow/tf-operator/pkg/common/jobcontroller"
"github.com/kubeflow/tf-operator/pkg/common/util/v1/testutil"
)

Expand Down Expand Up @@ -51,9 +52,10 @@ func TestGenLabels(t *testing.T) {
expctedKey := "test-key"

labels := testutil.GenLabels(testKey)
jobNamelabel := jobcontroller.JobNameLabel

if labels[labelTFJobName] != expctedKey {
t.Errorf("Expected %s %s, got %s", labelTFJobName, expctedKey, labels[labelTFJobName])
if labels[jobNamelabel] != expctedKey {
t.Errorf("Expected %s %s, got %s", jobNamelabel, expctedKey, jobNamelabel)
}
if labels[labelGroupName] != tfv1.GroupName {
t.Errorf("Expected %s %s, got %s", labelGroupName, tfv1.GroupName, labels[labelGroupName])
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller.v1beta2/tensorflow/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"k8s.io/apimachinery/pkg/types"

tfv1beta2 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1beta2"
"github.com/kubeflow/tf-operator/pkg/common/jobcontroller"
"github.com/kubeflow/tf-operator/pkg/common/util/v1beta2/testutil"
)

Expand Down Expand Up @@ -51,10 +52,12 @@ func TestGenLabels(t *testing.T) {
expctedKey := "test-key"

labels := testutil.GenLabels(testKey)
jobNamelabel := jobcontroller.JobNameLabel

if labels[labelTFJobName] != expctedKey {
t.Errorf("Expected %s %s, got %s", labelTFJobName, expctedKey, labels[labelTFJobName])
if labels[jobNamelabel] != expctedKey {
t.Errorf("Expected %s %s, got %s", jobNamelabel, expctedKey, jobNamelabel)
}

if labels[labelGroupName] != tfv1beta2.GroupName {
t.Errorf("Expected %s %s, got %s", labelGroupName, tfv1beta2.GroupName, labels[labelGroupName])
}
Expand Down

0 comments on commit 29dae72

Please sign in to comment.