@@ -68,13 +68,6 @@ func TestArgocdPlugin(t *testing.T) {
68
68
want : ErrMarshallingBody .Error (),
69
69
status : http .StatusBadRequest ,
70
70
},
71
- {
72
- name : "succeed marshalling body" ,
73
- body : bytes .NewReader ([]byte (`"lol": "test"` )),
74
- headers : headerContentJson ,
75
- want : "Success" ,
76
- status : http .StatusBadRequest ,
77
- },
78
71
}
79
72
80
73
for _ , tt := range failTests {
@@ -94,49 +87,31 @@ func TestArgocdPlugin(t *testing.T) {
94
87
})
95
88
}
96
89
97
- }
98
-
99
- // var tests = []struct {
100
- // name string
101
- // request executor.ExecuteTemplateArgs
102
- // want string
103
- // status int
104
- // }{
105
- // {
106
- // "parse body and return success",
107
- // executor.ExecuteTemplateArgs{
108
- // Workflow: &executor.Workflow{
109
- // ObjectMeta: executor.ObjectMeta{Name: "workflow"},
110
- // },
111
- // Template: &v1alpha1.Template{
112
- // Name: "my-tmpl",
113
- // Plugin: &v1alpha1.Plugin{
114
- // Object: v1alpha1.Object{Value: json.RawMessage(
115
- // `{
116
- // "argocd": {}
117
- // }`)},
118
- // },
119
- // },
120
- // },
121
- // `{"node": { "phase": "Succeeded", "message": "Succeeded"}}`,
122
- // http.StatusOK,
123
- // },
124
- // }
125
-
126
- // kubeClient := fake.NewSimpleClientset()
127
- // argocdPlugin := ArgocdPlugin(kubeClient, "argo")
128
- // handler := http.HandlerFunc(argocdPlugin)
129
-
130
- // for _, tt := range tests {
131
- // t.Run(tt.name, func(t *testing.T) {
132
- // body, _ := json.Marshal(&tt.request)
133
- // request, _ := http.NewRequest(http.MethodPost, "/api/v1/template.execute", bytes.NewReader(body))
134
- // response := httptest.NewRecorder()
135
-
136
- // handler.ServeHTTP(response, request)
137
-
138
-
139
- // common.AssertResponseBody(t, response.Body.String(), tt.want)
140
- // common.AssertStatus(t, response.Code, tt.status)
141
- // })
142
- // }
90
+ t .Run ("succeed marshalling body and execute the request" , func (t * testing.T ) {
91
+ body := bytes .NewReader ([]byte (
92
+ `{
93
+ "workflow": {
94
+ "metadata": {
95
+ "name": "test-template"
96
+ }
97
+ },
98
+ "template": {
99
+ "name": "argocd-plugin",
100
+ "inputs": {},
101
+ "outputs": {},
102
+ "plugin": {
103
+ "argocd": {
104
+ }
105
+ }
106
+ }
107
+ }` ))
108
+ request , _ := http .NewRequest (http .MethodPost , "/api/v1/template.execute" , body )
109
+ request .Header .Set ("Content-Type" , "application/json" )
110
+ response := httptest .NewRecorder ()
111
+ handler .ServeHTTP (response , request )
112
+
113
+ got := response .Code
114
+
115
+ common .AssertStatus (t , got , http .StatusOK )
116
+ })
117
+ }
0 commit comments