@@ -16,27 +16,26 @@ limitations under the License.
1616
1717package apps
1818
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"
3131
3232 "github.com/google/uuid"
3333 basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock"
34- "github.com/stretchr/testify/require"
3534
36- // "github.com/golang/mock/gomock"
35+ "github.com/golang/mock/gomock"
3736
38- // "github.com/meroxa/cli/log"
39- // )
37+ "github.com/meroxa/cli/log"
38+ )
4039
4140const (
4241 body = `
@@ -60,7 +59,7 @@ const (
6059 "pipeline_filename": "test-pipeline-1.yaml",
6160 "pipeline_original": "pipeline original settings",
6261 "state": "provisioned",
63- "stream_tech ": "kafka",
62+ "stream_provider ": "kafka",
6463 "updated": "2024-04-01 20:13:20.111Z"
6564 }
6665 ]
@@ -69,29 +68,29 @@ const (
6968 `
7069)
7170
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+ }
9594
9695func TestDescribeApplicationExecution (t * testing.T ) {
9796 ctx := context .Background ()
@@ -105,20 +104,6 @@ func TestDescribeApplicationExecution(t *testing.T) {
105104 t .Fatalf ("not expected error, got \" %s\" " , err .Error ())
106105 }
107106
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-
122107 a := & Application {
123108 Name : "test-pipeline-1" ,
124109 State : "provisioned" ,
@@ -131,14 +116,8 @@ func TestDescribeApplicationExecution(t *testing.T) {
131116 ApplicationSpec : "kafka" ,
132117 }
133118
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 ))
142121
143122 httpResp := & http.Response {
144123 Body : io .NopCloser (strings .NewReader (body )),
@@ -159,10 +138,10 @@ func TestDescribeApplicationExecution(t *testing.T) {
159138 }{Path : filepath .Join (path , "appName" )},
160139 }
161140
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+ }
166145
167146 var gotApp Application
168147 err = json .Unmarshal ([]byte (logger .JSONOutput ()), & gotApp )
0 commit comments