-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kn export defect to honor mode #1212
Changes from all commits
1306b06
d4cdcf2
b0bb594
615e8f5
f5b1635
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,6 @@ func TestServiceExportError(t *testing.T) { | |
|
||
_, err := executeServiceExportCommand(t, tc, "export", tc.latestSvc.ObjectMeta.Name) | ||
assert.Error(t, err, "'kn service export' requires output format") | ||
|
||
_, err = executeServiceExportCommand(t, tc, "export", tc.latestSvc.ObjectMeta.Name, "--with-revisions", "-o", "json") | ||
assert.Error(t, err, "'kn service export --with-revisions' requires a mode, please specify one of replay|export") | ||
|
||
_, err = executeServiceExportCommand(t, tc, "export", tc.latestSvc.ObjectMeta.Name, "--with-revisions", "--mode", "k8s", "-o", "yaml") | ||
assert.Error(t, err, "'kn service export --with-revisions' requires a mode, please specify one of replay|export") | ||
} | ||
|
||
func TestServiceExport(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have a similar set of tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added this test |
||
|
@@ -73,12 +67,16 @@ func TestServiceExport(t *testing.T) { | |
{latestSvc: libtest.BuildServiceWithOptions("foo", servingtest.WithConfigSpec(buildConfiguration()), servingtest.WithServiceLabel("a", "mouse"), servingtest.WithServiceAnnotation("a", "mouse"))}, | ||
{latestSvc: libtest.BuildServiceWithOptions("foo", servingtest.WithConfigSpec(buildConfiguration()), servingtest.WithVolume("secretName", "/mountpath", volumeSource("secretName")))}, | ||
} { | ||
exportServiceTest(t, &tc) | ||
exportServiceTestForReplay(t, &tc) | ||
tc.expectedKNExport = libtest.BuildKNExportWithOptions() | ||
exportServiceTest(t, &tc, true) | ||
//test default | ||
exportServiceTest(t, &tc, false) | ||
} | ||
} | ||
|
||
func exportServiceTest(t *testing.T, tc *testCase) { | ||
output, err := executeServiceExportCommand(t, tc, "export", tc.latestSvc.ObjectMeta.Name, "-o", "yaml") | ||
func exportServiceTestForReplay(t *testing.T, tc *testCase) { | ||
output, err := executeServiceExportCommand(t, tc, "export", tc.latestSvc.ObjectMeta.Name, "--mode", "replay", "-o", "yaml") | ||
assert.NilError(t, err) | ||
|
||
actSvc := servingv1.Service{} | ||
|
@@ -88,6 +86,23 @@ func exportServiceTest(t *testing.T, tc *testCase) { | |
assert.DeepEqual(t, tc.latestSvc, &actSvc) | ||
} | ||
|
||
func exportServiceTest(t *testing.T, tc *testCase, addMode bool) { | ||
args := []string{"export", tc.latestSvc.ObjectMeta.Name, "-o", "json"} | ||
if addMode { | ||
args = append(args, []string{"--mode", "export"}...) | ||
} | ||
output, err := executeServiceExportCommand(t, tc, args...) | ||
assert.NilError(t, err) | ||
|
||
tc.expectedKNExport.Spec.Service = *tc.latestSvc | ||
|
||
actKNExport := &clientv1alpha1.Export{} | ||
err = json.Unmarshal([]byte(output), actKNExport) | ||
assert.NilError(t, err) | ||
|
||
assert.DeepEqual(t, tc.expectedKNExport, actKNExport) | ||
} | ||
|
||
func TestServiceExportwithMultipleRevisions(t *testing.T) { | ||
for _, tc := range []testCase{{ | ||
name: "test 2 revisions with traffic split", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a simple test verifying no latest revision in export?