Skip to content

Commit 6e93a2d

Browse files
author
anna-cross
committed
update few details on tests and requests
1 parent 094909d commit 6e93a2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+9887
-257
lines changed

cmd/meroxa/global/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
)
3434

3535
func GetMeroxaTenantURL() string {
36-
return getEnvVal([]string{"TENANT_URL"}, "https://api.meroxa.io")
36+
return getEnvVal([]string{"TENANT_URL"}, "https://test.na1.meroxa.cloud")
3737
}
3838

3939
func GetMeroxaTenantUser() string {

cmd/meroxa/root/apps/apps.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ const (
4949
var displayDetails = display.Details{
5050
"Name": "name",
5151
"State": "state",
52-
"ApplicationSpec": "stream_tech",
52+
"Application Spec": "stream_tech",
5353
"Config": "config",
54-
"PipelineFilenames": "pipelines_filenames",
54+
"Pipeline Filename": "pipeline_filename",
55+
"Stream Provider": "stream_provider",
5556
// "PipelineEnriched": "pipeline_enriched",
5657
// "PipelineOriginal": "pipeline_original",
5758
"Created": "created",
@@ -85,11 +86,12 @@ type Application struct {
8586
DeploymentID []string `json:"deployment_id"`
8687
Name string `json:"name"`
8788
State string `json:"state"`
88-
ApplicationSpec string `json:"stream_tech"`
89+
ApplicationSpec string `json:"stream_provider"`
8990
Config string `json:"config"`
9091
PipelineFilenames string `json:"pipeline_filename"`
9192
PipelineEnriched string `json:"pipeline_enriched"`
9293
PipelineOriginal string `json:"pipeline_original"`
94+
PipelineDraft string `json:"pipeline_draft"`
9395

9496
Created AppTime `json:"created"`
9597
Updated AppTime `json:"updated"`

cmd/meroxa/root/apps/deploy_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ func TestDeployAppFlags(t *testing.T) {
1717
{name: "path", required: false},
1818
}
1919

20+
c := builder.BuildCobraCommand(&Deploy{})
21+
22+
for _, f := range expectedFlags {
23+
cf := c.Flags().Lookup(f.name)
24+
if cf == nil {
25+
t.Fatalf("expected flag \"%s\" to be present", f.name)
26+
}
27+
28+
if f.shorthand != cf.Shorthand {
29+
t.Fatalf("expected shorthand \"%s\" got \"%s\" for flag \"%s\"", f.shorthand, cf.Shorthand, f.name)
30+
}
31+
32+
if f.required && !utils.IsFlagRequired(cf) {
33+
t.Fatalf("expected flag \"%s\" to be required", f.name)
34+
}
2035

2136
if cf.Hidden != f.hidden {
2237
if cf.Hidden {

cmd/meroxa/root/apps/describe.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (d *Describe) Execute(ctx context.Context) error {
7373
for _, app := range apps.Items {
7474
d.logger.Info(ctx, display.PrintTable(app, displayDetails))
7575
d.logger.JSON(ctx, app)
76-
dashboardURL := fmt.Sprintf("%s/conduitapps/%s/detail", global.GetMeroxaTenantURL(), app.ID)
76+
dashboardURL := fmt.Sprintf("%s/apps/%s", global.GetMeroxaTenantURL(), app.ID)
7777
d.logger.Info(ctx, fmt.Sprintf("\n ✨ To view your application, visit %s", dashboardURL))
7878
}
7979

cmd/meroxa/root/apps/describe_test.go

+45-66
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,26 @@ limitations under the License.
1616

1717
package 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

4140
const (
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

9695
func 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)

cmd/meroxa/root/apps/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (l *List) Execute(ctx context.Context) error {
7070
l.logger.Info(ctx, display.PrintList(apps.Items, displayDetails))
7171
l.logger.JSON(ctx, apps)
7272

73-
output := fmt.Sprintf("\n ✨ To view your applications, visit %s/conduitapps", global.GetMeroxaTenantURL())
73+
output := fmt.Sprintf("\n ✨ To view your applications, visit %s/apps", global.GetMeroxaTenantURL())
7474
l.logger.Info(ctx, output)
7575
return nil
7676
}

cmd/meroxa/root/apps/list_test.go

+34-39
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@ limitations under the License.
1616

1717
package apps
1818

19-
// import (
20-
// "context"
21-
// "encoding/json"
22-
// "fmt"
23-
// "io"
24-
// "net/http"
25-
// "net/url"
26-
// "strings"
27-
// "testing"
28-
29-
// "github.com/meroxa/cli/log"
30-
31-
// "github.com/golang/mock/gomock"
32-
// basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock"
33-
// )
34-
35-
// func TestListApplicationExecution(t *testing.T) {
36-
// ctx := context.Background()
37-
// ctrl := gomock.NewController(t)
38-
// client := basicMock.NewMockBasicClient(ctrl)
39-
// logger := log.NewTestLogger()
19+
import (
20+
"context"
21+
"encoding/json"
22+
"io"
23+
"net/http"
24+
"strings"
25+
"testing"
26+
27+
"github.com/meroxa/cli/log"
28+
29+
"github.com/golang/mock/gomock"
30+
basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock"
31+
)
32+
33+
func TestListApplicationExecution(t *testing.T) {
34+
ctx := context.Background()
35+
ctrl := gomock.NewController(t)
36+
client := basicMock.NewMockBasicClient(ctrl)
37+
logger := log.NewTestLogger()
4038

4139
appTime := AppTime{}
4240
err := appTime.UnmarshalJSON([]byte(`"2024-04-01 20:13:20.111Z"`))
@@ -58,10 +56,7 @@ package apps
5856
Updated: appTime,
5957
}
6058

61-
// allApps := []Application{*a, *a2}
62-
63-
// filter := &url.Values{}
64-
// filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name))
59+
allApps := []Application{*a, *a2}
6560

6661
httpResp := &http.Response{
6762
Body: io.NopCloser(strings.NewReader(body)),
@@ -73,23 +68,23 @@ package apps
7368
nil,
7469
)
7570

76-
// list := &List{
77-
// client: client,
78-
// logger: logger,
79-
// }
71+
list := &List{
72+
client: client,
73+
logger: logger,
74+
}
8075

81-
// err = list.Execute(ctx)
82-
// if err != nil {
83-
// t.Fatalf("not expected error, got %q", err.Error())
84-
// }
76+
err = list.Execute(ctx)
77+
if err != nil {
78+
t.Fatalf("not expected error, got %q", err.Error())
79+
}
8580

86-
// gotJSONOutput := logger.JSONOutput()
81+
gotJSONOutput := logger.JSONOutput()
8782

88-
// var gotApp Applications
89-
// err = json.Unmarshal([]byte(gotJSONOutput), &gotApp)
90-
// if err != nil {
91-
// t.Fatalf("not expected error, got %q", err.Error())
92-
// }
83+
var gotApp Applications
84+
err = json.Unmarshal([]byte(gotJSONOutput), &gotApp)
85+
if err != nil {
86+
t.Fatalf("not expected error, got %q", err.Error())
87+
}
9388

9489
for i, app := range gotApp.Items {
9590
if app.Name != allApps[i].Name {

cmd/meroxa/root/apps/open.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (o *Open) Execute(ctx context.Context) error {
101101
}
102102

103103
// open a browser window to the application details
104-
dashboardURL := fmt.Sprintf("%s/apps/%s/detail", global.GetMeroxaTenantURL(), apps.Items[0].ID)
104+
dashboardURL := fmt.Sprintf("%s/apps/%s", global.GetMeroxaTenantURL(), apps.Items[0].ID)
105105
err = o.Start(dashboardURL)
106106
if err != nil {
107107
o.logger.Errorf(ctx, "can't open browser to URL %s\n", dashboardURL)

0 commit comments

Comments
 (0)