Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EdSwordsmith committed Jan 28, 2025
1 parent 6a35438 commit 306a698
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 91 deletions.
1 change: 1 addition & 0 deletions services/cd-service/pkg/service/overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ func CalculateWarnings(appDeployments map[string]db.Deployment, appLocks []db.Ap

func (o *OverviewServiceServer) StreamDeploymentHistory(in *api.DeploymentHistoryRequest,
stream api.OverviewService_StreamDeploymentHistoryServer) error {
// this is temporary, the endpoint will return actual data when SRX-AJJ2X3 is completed
stream.Send(&api.DeploymentHistoryResponse{Deployment: "1,hello\n"})
stream.Send(&api.DeploymentHistoryResponse{Deployment: "2,world\n"})
stream.Send(&api.DeploymentHistoryResponse{Deployment: "3,from the\n"})
Expand Down
92 changes: 58 additions & 34 deletions services/cd-service/pkg/service/overview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,40 +670,6 @@ func TestOverviewService(t *testing.T) {
}
},
},
{
Name: "Test deployment history stream",
Setup: []repository.Transformer{},
Test: func(t *testing.T, svc *OverviewServiceServer) {
ctx := testutil.MakeTestContext()
ch := make(chan *api.DeploymentHistoryResponse)
stream := mockOverviewService_DeploymentHistoryServer{
Results: ch,
Ctx: ctx,
}

wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
err := svc.StreamDeploymentHistory(&api.DeploymentHistoryRequest{}, &stream)
close(ch)
if err != nil {
t.Fatal(err)
}
}()

dummyCsvLines := []string{"1,hello\n", "2,world\n", "3,from the\n", "4,cd-service\n"}
line := 0
for got := range ch {
if got.Deployment != dummyCsvLines[line] {
t.Errorf("%q doesn't match %q from line %d of dummy csv file", got.Deployment, dummyCsvLines[line], line)
}
line += 1
}

wg.Wait()
},
},
}
for _, tc := range tcs {
tc := tc
Expand Down Expand Up @@ -2314,6 +2280,64 @@ func TestCalculateWarnings(t *testing.T) {
}
}

func TestDeploymentHistory(t *testing.T) {
tcs := []struct {
Name string
Test func(t *testing.T, svc *OverviewServiceServer)
}{
{
Name: "Test deployment history stream",
Test: func(t *testing.T, svc *OverviewServiceServer) {
ctx := testutil.MakeTestContext()
ch := make(chan *api.DeploymentHistoryResponse)
stream := mockOverviewService_DeploymentHistoryServer{
Results: ch,
Ctx: ctx,
}

wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
err := svc.StreamDeploymentHistory(&api.DeploymentHistoryRequest{}, &stream)
close(ch)
if err != nil {
t.Fatal(err)
}
}()

// this is temporary, the endpoint will return actual data when SRX-AJJ2X3 is completed
dummyCsvLines := []string{"1,hello\n", "2,world\n", "3,from the\n", "4,cd-service\n"}
line := 0
for got := range ch {
if got.Deployment != dummyCsvLines[line] {
t.Errorf("%q doesn't match %q from line %d of dummy csv file", got.Deployment, dummyCsvLines[line], line)
}
line += 1
}

wg.Wait()
},
},
}
for _, tc := range tcs {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
shutdown := make(chan struct{}, 1)
var repo repository.Repository
ctx := testutil.MakeTestContext()
svc := &OverviewServiceServer{
Repository: repo,
Shutdown: shutdown,
DBHandler: repo.State().DBHandler,
Context: ctx,
}
tc.Test(t, svc)
close(shutdown)
})
}
}

func getAppDetailsIgnoredTypes() cmp.Option {
return cmpopts.IgnoreUnexported(api.GetAppDetailsResponse{},
api.Deployment{},
Expand Down
57 changes: 0 additions & 57 deletions services/frontend-service/src/ui/App/routes.tsx

This file was deleted.

0 comments on commit 306a698

Please sign in to comment.