|
99 | 99 | assert.Equal(t, 400, rec.Code)
|
100 | 100 | }
|
101 | 101 |
|
| 102 | +func Test_putPipelineImportJSONWithoutVersionHandler(t *testing.T) { |
| 103 | + api, db, _, end := newTestAPI(t) |
| 104 | + defer end() |
| 105 | + |
| 106 | + u, pass := assets.InsertAdminUser(t, db) |
| 107 | + proj := assets.InsertTestProject(t, db, api.Cache, sdk.RandomString(10), sdk.RandomString(10)) |
| 108 | + test.NotNil(t, proj) |
| 109 | + |
| 110 | + //Prepare request |
| 111 | + vars := map[string]string{ |
| 112 | + "permProjectKey": proj.Key, |
| 113 | + "pipelineKey": "testest", |
| 114 | + } |
| 115 | + uri := api.Router.GetRoute("PUT", api.putImportPipelineHandler, vars) |
| 116 | + test.NotEmpty(t, uri) |
| 117 | + req := assets.NewAuthentifiedRequest(t, u, pass, "PUT", uri+"?format=json", nil) |
| 118 | + |
| 119 | + bodyjson := `{"name":"testest","stages":["Stage 1"],"jobs":[{"job":"echo with default","stage":"Stage 1","steps":[{"script":["echo \"test\"","echo {{.limit | default \"\"}}"]}]}]}` |
| 120 | + req.Body = ioutil.NopCloser(strings.NewReader(bodyjson)) |
| 121 | + req.Header.Set("Content-Type", "application/json") |
| 122 | + |
| 123 | + //Do the request |
| 124 | + rec := httptest.NewRecorder() |
| 125 | + api.Router.Mux.ServeHTTP(rec, req) |
| 126 | + assert.Equal(t, 200, rec.Code) |
| 127 | +} |
| 128 | + |
102 | 129 | func Test_putPipelineImportDifferentStageHandler(t *testing.T) {
|
103 | 130 | api, db, _, end := newTestAPI(t)
|
104 | 131 | defer end()
|
|
0 commit comments