@@ -16,27 +16,26 @@ limitations under the License.
16
16
17
17
package apps
18
18
19
- // import (
20
- // "context"
21
- // "encoding/json"
22
- // "errors"
23
- // "fmt"
24
- // "io"
25
- // "net/http"
26
- // "net/url"
27
- // "os"
28
- // "path/filepath"
29
- // "strings"
30
- // "testing"
19
+ import (
20
+ "context"
21
+ "encoding/json"
22
+ "errors"
23
+ "fmt"
24
+ "io"
25
+ "net/http"
26
+ "net/url"
27
+ "os"
28
+ "path/filepath"
29
+ "strings"
30
+ "testing"
31
31
32
32
"github.com/google/uuid"
33
33
basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock"
34
- "github.com/stretchr/testify/require"
35
34
36
- // "github.com/golang/mock/gomock"
35
+ "github.com/golang/mock/gomock"
37
36
38
- // "github.com/meroxa/cli/log"
39
- // )
37
+ "github.com/meroxa/cli/log"
38
+ )
40
39
41
40
const (
42
41
body = `
@@ -60,7 +59,7 @@ const (
60
59
"pipeline_filename": "test-pipeline-1.yaml",
61
60
"pipeline_original": "pipeline original settings",
62
61
"state": "provisioned",
63
- "stream_tech ": "kafka",
62
+ "stream_provider ": "kafka",
64
63
"updated": "2024-04-01 20:13:20.111Z"
65
64
}
66
65
]
@@ -69,29 +68,29 @@ const (
69
68
`
70
69
)
71
70
72
- // func TestDescribeApplicationArgs(t *testing.T) {
73
- // tests := []struct {
74
- // args []string
75
- // err error
76
- // name string
77
- // }{
78
- // {args: nil, err: errors.New("requires app name or UUID"), name: ""},
79
- // {args: []string{"ApplicationName"}, err: nil, name: "ApplicationName"},
80
- // }
81
-
82
- // for _, tt := range tests {
83
- // ar := &Describe{}
84
- // err := ar.ParseArgs(tt.args)
85
-
86
- // if err != nil && tt.err.Error() != err.Error() {
87
- // t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err)
88
- // }
89
-
90
- // if tt.name != ar.args.nameOrUUID {
91
- // t.Fatalf("expected \"%s\" got \"%s\"", tt.name, ar.args.nameOrUUID)
92
- // }
93
- // }
94
- // }
71
+ func TestDescribeApplicationArgs (t * testing.T ) {
72
+ tests := []struct {
73
+ args []string
74
+ err error
75
+ name string
76
+ }{
77
+ {args : nil , err : errors .New ("requires app name or UUID" ), name : "" },
78
+ {args : []string {"ApplicationName" }, err : nil , name : "ApplicationName" },
79
+ }
80
+
81
+ for _ , tt := range tests {
82
+ ar := & Describe {}
83
+ err := ar .ParseArgs (tt .args )
84
+
85
+ if err != nil && tt .err .Error () != err .Error () {
86
+ t .Fatalf ("expected \" %s\" got \" %s\" " , tt .err , err )
87
+ }
88
+
89
+ if tt .name != ar .args .nameOrUUID {
90
+ t .Fatalf ("expected \" %s\" got \" %s\" " , tt .name , ar .args .nameOrUUID )
91
+ }
92
+ }
93
+ }
95
94
96
95
func TestDescribeApplicationExecution (t * testing.T ) {
97
96
ctx := context .Background ()
@@ -105,20 +104,6 @@ func TestDescribeApplicationExecution(t *testing.T) {
105
104
t .Fatalf ("not expected error, got \" %s\" " , err .Error ())
106
105
}
107
106
108
- i := & Init {
109
- logger : logger ,
110
- args : struct { appName string }{appName : "test-pipeline-1" },
111
- flags : struct {
112
- Path string "long:\" path\" usage:\" path where application will be initialized (current directory as default)\" "
113
- ModVendor bool "long:\" mod-vendor\" usage:\" whether to download modules to vendor or globally while initializing a Go application\" "
114
- SkipModInit bool "long:\" skip-mod-init\" usage:\" whether to run 'go mod init' while initializing a Go application\" "
115
- }{
116
- Path : path ,
117
- ModVendor : false ,
118
- SkipModInit : true ,
119
- },
120
- }
121
-
122
107
a := & Application {
123
108
Name : "test-pipeline-1" ,
124
109
State : "provisioned" ,
@@ -131,14 +116,8 @@ func TestDescribeApplicationExecution(t *testing.T) {
131
116
ApplicationSpec : "kafka" ,
132
117
}
133
118
134
- // err = i.Execute(ctx)
135
- // defer func(path string) {
136
- // os.RemoveAll(path)
137
- // }(path)
138
- // require.NoError(t, err)
139
-
140
- // filter := &url.Values{}
141
- // filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name))
119
+ filter := & url.Values {}
120
+ filter .Add ("filter" , fmt .Sprintf ("(id='%s' || name='%s')" , a .Name , a .Name ))
142
121
143
122
httpResp := & http.Response {
144
123
Body : io .NopCloser (strings .NewReader (body )),
@@ -159,10 +138,10 @@ func TestDescribeApplicationExecution(t *testing.T) {
159
138
}{Path : filepath .Join (path , "appName" )},
160
139
}
161
140
162
- // err = dc.Execute(ctx)
163
- // if err != nil {
164
- // t.Fatalf("not expected error, got %q", err.Error())
165
- // }
141
+ err = dc .Execute (ctx )
142
+ if err != nil {
143
+ t .Fatalf ("not expected error, got %q" , err .Error ())
144
+ }
166
145
167
146
var gotApp Application
168
147
err = json .Unmarshal ([]byte (logger .JSONOutput ()), & gotApp )
0 commit comments