Skip to content

Commit a895d11

Browse files
committed
tests(*): remove "*Malformed" test cases since 2.14.4 doesn't return parsing errors
swagger-api/swagger-codegen#10429 will add that ability back in.
1 parent 9e85eca commit a895d11

File tree

5 files changed

+1
-291
lines changed

5 files changed

+1
-291
lines changed

cmd/account/get_test.go

-35
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,6 @@ func TestAccountGet_flags(t *testing.T) {
107107
}
108108
}
109109

110-
func TestAccountGet_malformed(t *testing.T) {
111-
ts := testGateAccountGetMalformed()
112-
defer ts.Close()
113-
114-
rootCmd, rootOpts := cmd.NewCmdRoot(ioutil.Discard, ioutil.Discard)
115-
rootCmd.AddCommand(NewAccountCmd(rootOpts))
116-
117-
args := []string{"account", "get", ACCOUNT, "--gate-endpoint=" + ts.URL}
118-
rootCmd.SetArgs(args)
119-
err := rootCmd.Execute()
120-
if err == nil { // Success is actually failure here, return payload is malformed.
121-
t.Fatalf("Command failed with: %d", err)
122-
}
123-
}
124-
125110
func TestAccountGet_fail(t *testing.T) {
126111
ts := testGateFail()
127112
defer ts.Close()
@@ -148,26 +133,6 @@ func testGateAccountGetSuccess() *httptest.Server {
148133
return httptest.NewServer(mux)
149134
}
150135

151-
// testGateAccountGetMalformed returns a malformed list of pipeline configs.
152-
func testGateAccountGetMalformed() *httptest.Server {
153-
mux := util.TestGateMuxWithVersionHandler()
154-
mux.Handle("/credentials/"+ACCOUNT, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
155-
fmt.Fprintln(w, strings.TrimSpace(malformedAccountGetJson))
156-
}))
157-
return httptest.NewServer(mux)
158-
}
159-
160-
const malformedAccountGetJson = `
161-
"type": "kubernetes",
162-
"providerVersion": "v2",
163-
"environment": "self",
164-
"skin": "v2",
165-
"name": "self",
166-
"cloudProvider": "kubernetes",
167-
"accountType": "self"
168-
}
169-
`
170-
171136
const accountJson = `
172137
{
173138
"type": "kubernetes",

cmd/account/list_test.go

-39
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ func TestAccountList_basic(t *testing.T) {
4141
}
4242
}
4343

44-
func TestAccountList_malformed(t *testing.T) {
45-
ts := testGateAccountListMalformed()
46-
defer ts.Close()
47-
48-
rootCmd, options := cmd.NewCmdRoot(ioutil.Discard, ioutil.Discard)
49-
rootCmd.AddCommand(NewAccountCmd(options))
50-
51-
args := []string{"account", "list", "--gate-endpoint=" + ts.URL}
52-
rootCmd.SetArgs(args)
53-
err := rootCmd.Execute()
54-
if err == nil {
55-
t.Fatalf("Command failed with: %s", err)
56-
}
57-
}
58-
5944
func TestAccountList_fail(t *testing.T) {
6045
ts := testGateFail()
6146
defer ts.Close()
@@ -80,30 +65,6 @@ func testGateAccountListSuccess() *httptest.Server {
8065
return httptest.NewServer(mux)
8166
}
8267

83-
func testGateAccountListMalformed() *httptest.Server {
84-
mux := util.TestGateMuxWithVersionHandler()
85-
mux.Handle("/credentials/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
86-
fmt.Fprintln(w, strings.TrimSpace(malformedAccountListJson))
87-
}))
88-
return httptest.NewServer(mux)
89-
}
90-
91-
const malformedAccountListJson = `
92-
{
93-
"type": "kubernetes",
94-
"skin": "v2",
95-
"providerVersion": "v2",
96-
"name": "foobar"
97-
},
98-
{
99-
"type": "dockerRegistry",
100-
"skin": "v1",
101-
"providerVersion": "v1",
102-
"name": "dockerhub"
103-
}
104-
]
105-
`
106-
10768
const accountListJson = `[
10869
{
10970
"type": "kubernetes",

cmd/pipeline-template/get_test.go

+1-80
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,6 @@ func TestPipelineGet_flags(t *testing.T) {
122122
}
123123
}
124124

125-
func TestPipelineGet_malformed(t *testing.T) {
126-
ts := testGatePipelineTemplateGetMalformed()
127-
defer ts.Close()
128-
129-
rootCmd, rootOpts := cmd.NewCmdRoot(ioutil.Discard, ioutil.Discard)
130-
rootCmd.AddCommand(NewPipelineTemplateCmd(rootOpts))
131-
132-
args := []string{"pipeline-template", "get", "--id", "newSpelTemplate", "--gate-endpoint", ts.URL}
133-
rootCmd.SetArgs(args)
134-
135-
err := rootCmd.Execute()
136-
if err == nil {
137-
t.Fatalf("Command failed with: %s", err)
138-
}
139-
}
140-
141125
func TestPipelineGet_fail(t *testing.T) {
142126
ts := testGateFail()
143127
defer ts.Close()
@@ -175,20 +159,12 @@ func TestPipelineGet_notfound(t *testing.T) {
175159
func testGatePipelineTemplateGetSuccess() *httptest.Server {
176160
mux := util.TestGateMuxWithVersionHandler()
177161
mux.Handle("/v2/pipelineTemplates/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
162+
w.Header().Add("content-type", "application/json")
178163
fmt.Fprintln(w, strings.TrimSpace(pipelineTemplateGetJson))
179164
}))
180165
return httptest.NewServer(mux)
181166
}
182167

183-
// testGatePipelineGetMalformed returns a malformed get response of pipeline configs.
184-
func testGatePipelineTemplateGetMalformed() *httptest.Server {
185-
mux := util.TestGateMuxWithVersionHandler()
186-
mux.Handle("/v2/pipelineTemplates/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
187-
fmt.Fprintln(w, strings.TrimSpace(malformedPipelineTemplateGetJson))
188-
}))
189-
return httptest.NewServer(mux)
190-
}
191-
192168
// testGatePipelineGetMissing returns a 404 Not Found for an errant pipeline name|application pair.
193169
func testGatePipelineTemplateGetMissing() *httptest.Server {
194170
mux := util.TestGateMuxWithVersionHandler()
@@ -207,61 +183,6 @@ func testGateFail() *httptest.Server {
207183
}))
208184
}
209185

210-
const malformedPipelineTemplateGetJson = `
211-
"id": "newSpelTemplate",
212-
"lastModifiedBy": "anonymous",
213-
"metadata": {
214-
"description": "A generic application bake and tag pipeline.",
215-
"name": "Default Bake and Tag",
216-
"owner": "[email protected]",
217-
"scopes": [
218-
"global"
219-
]
220-
},
221-
"pipeline": {
222-
"description": "",
223-
"keepWaitingPipelines": false,
224-
"lastModifiedBy": "anonymous",
225-
"limitConcurrent": true,
226-
"notifications": [],
227-
"parameterConfig": [],
228-
"stages": [
229-
{
230-
"name": "My Wait Stage",
231-
"refId": "wait1",
232-
"requisiteStageRefIds": [],
233-
"type": "wait",
234-
"waitTime": "${ templateVariables.waitTime }"
235-
}
236-
],
237-
"triggers": [
238-
{
239-
"attributeConstraints": {},
240-
"enabled": true,
241-
"payloadConstraints": {},
242-
"pubsubSystem": "google",
243-
"source": "jtk54",
244-
"subscription": "super-pub",
245-
"subscriptionName": "super-pub",
246-
"type": "pubsub"
247-
}
248-
],
249-
"updateTs": "1543509523663"
250-
},
251-
"protect": false,
252-
"schema": "v2",
253-
"updateTs": "1543860678988",
254-
"variables": [
255-
{
256-
"defaultValue": 42,
257-
"description": "The time a wait stage shall pauseth",
258-
"name": "waitTime",
259-
"type": "int"
260-
}
261-
]
262-
}
263-
`
264-
265186
const pipelineTemplateGetJson = `
266187
{
267188
"id": "newSpelTemplate",

cmd/pipeline-template/list_test.go

-81
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ func TestPipelineTemplateList_scope(t *testing.T) {
5656
}
5757
}
5858

59-
func TestPipelineTemplateList_malformed(t *testing.T) {
60-
ts := testGatePipelineTemplateListMalformed()
61-
defer ts.Close()
62-
63-
rootCmd, rootOpts := cmd.NewCmdRoot(ioutil.Discard, ioutil.Discard)
64-
rootCmd.AddCommand(NewPipelineTemplateCmd(rootOpts))
65-
66-
args := []string{"pipeline-template", "list", "--gate-endpoint", ts.URL}
67-
rootCmd.SetArgs(args)
68-
err := rootCmd.Execute()
69-
if err == nil {
70-
t.Fatalf("Command failed with: %s", err)
71-
}
72-
}
73-
7459
func TestPipelineTemplateList_fail(t *testing.T) {
7560
ts := testGateFail()
7661
defer ts.Close()
@@ -106,72 +91,6 @@ func testGateScopedPipelineTemplateListSuccess() *httptest.Server {
10691
return httptest.NewServer(mux)
10792
}
10893

109-
// testGatePipelineTemplateListMalformed returns a malformed list of pipelineTemplate configs.
110-
func testGatePipelineTemplateListMalformed() *httptest.Server {
111-
mux := util.TestGateMuxWithVersionHandler()
112-
mux.Handle("/v2/pipelineTemplates/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
113-
fmt.Fprintln(w, strings.TrimSpace(malformedPipelineTemplateListJson))
114-
}))
115-
return httptest.NewServer(mux)
116-
}
117-
118-
const malformedPipelineTemplateListJson = `
119-
{
120-
"id": "newSpelTemplate",
121-
"lastModifiedBy": "anonymous",
122-
"metadata": {
123-
"description": "A generic application wait.",
124-
"name": "Default Wait",
125-
"owner": "[email protected]",
126-
"scopes": [
127-
"global"
128-
]
129-
},
130-
"pipeline": {
131-
"description": "",
132-
"keepWaitingPipelines": false,
133-
"lastModifiedBy": "anonymous",
134-
"limitConcurrent": true,
135-
"notifications": [],
136-
"parameterConfig": [],
137-
"stages": [
138-
{
139-
"name": "My Wait Stage",
140-
"refId": "wait1",
141-
"requisiteStageRefIds": [],
142-
"type": "wait",
143-
"waitTime": "${ templateVariables.waitTime }"
144-
}
145-
],
146-
"triggers": [
147-
{
148-
"attributeConstraints": {},
149-
"enabled": true,
150-
"payloadConstraints": {},
151-
"pubsubSystem": "google",
152-
"source": "jake",
153-
"subscription": "super-why",
154-
"subscriptionName": "super-why",
155-
"type": "pubsub"
156-
}
157-
],
158-
"updateTs": "1543509523663"
159-
},
160-
"protect": false,
161-
"schema": "v2",
162-
"updateTs": "1543860678988",
163-
"variables": [
164-
{
165-
"defaultValue": 42,
166-
"description": "The time a wait stage shall pauseth",
167-
"name": "waitTime",
168-
"type": "int"
169-
}
170-
]
171-
}
172-
]
173-
`
174-
17594
const pipelineTemplateListJson = `
17695
[
17796
{

cmd/pipeline/get_test.go

-56
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,6 @@ func TestPipelineGet_flags(t *testing.T) {
9191
}
9292
}
9393

94-
func TestPipelineGet_malformed(t *testing.T) {
95-
ts := testGatePipelineGetMalformed()
96-
defer ts.Close()
97-
98-
rootCmd, rootOpts := cmd.NewCmdRoot(ioutil.Discard, ioutil.Discard)
99-
pipelineCmd, _ := NewPipelineCmd(rootOpts)
100-
rootCmd.AddCommand(pipelineCmd)
101-
102-
args := []string{"pipeline", "get", "--application", "app", "--name", "one", "--gate-endpoint", ts.URL}
103-
rootCmd.SetArgs(args)
104-
err := rootCmd.Execute()
105-
if err == nil {
106-
t.Fatalf("Command failed with: %s", err)
107-
}
108-
}
109-
11094
func TestPipelineGet_fail(t *testing.T) {
11195
ts := testGateFail()
11296
defer ts.Close()
@@ -150,15 +134,6 @@ func testGatePipelineGetSuccess() *httptest.Server {
150134
return httptest.NewServer(mux)
151135
}
152136

153-
// testGatePipelineGetMalformed returns a malformed get response of pipeline configs.
154-
func testGatePipelineGetMalformed() *httptest.Server {
155-
mux := util.TestGateMuxWithVersionHandler()
156-
mux.Handle("/applications/app/pipelineConfigs/one", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
157-
fmt.Fprintln(w, strings.TrimSpace(malformedPipelineGetJson))
158-
}))
159-
return httptest.NewServer(mux)
160-
}
161-
162137
// testGatePipelineGetMissing returns a 404 Not Found for an errant pipeline name|application pair.
163138
func testGatePipelineGetMissing() *httptest.Server {
164139
mux := util.TestGateMuxWithVersionHandler()
@@ -168,37 +143,6 @@ func testGatePipelineGetMissing() *httptest.Server {
168143
return httptest.NewServer(mux)
169144
}
170145

171-
const malformedPipelineGetJson = `
172-
"application": "app",
173-
"id": "pipeline_one",
174-
"index": 0,
175-
"keepWaitingPipelines": false,
176-
"lastModifiedBy": "[email protected]",
177-
"limitConcurrent": true,
178-
"name": "one",
179-
"parameterConfig": [
180-
{
181-
"default": "blah",
182-
"description": "A foo.",
183-
"name": "foooB",
184-
"required": true
185-
}
186-
],
187-
"stages": [
188-
{
189-
"comments": "${ parameters.derp }",
190-
"name": "Wait",
191-
"refId": "1",
192-
"requisiteStageRefIds": [],
193-
"type": "wait",
194-
"waitTime": 30
195-
}
196-
],
197-
"triggers": [],
198-
"updateTs": "1526578883109"
199-
}
200-
`
201-
202146
const pipelineGetJson = `
203147
{
204148
"application": "app",

0 commit comments

Comments
 (0)