From b29306b2b34181aa5f1484ce69809210ac27c1f3 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Sat, 6 Apr 2024 17:39:49 +0200 Subject: [PATCH 1/2] fix(ui-extensions): use the new version response when returning --- pkg/c8y/uiExtension.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/c8y/uiExtension.go b/pkg/c8y/uiExtension.go index 46c5e5de..06852286 100644 --- a/pkg/c8y/uiExtension.go +++ b/pkg/c8y/uiExtension.go @@ -177,9 +177,9 @@ func (s *UIExtensionService) CreateExtension(ctx context.Context, application *A } // Upload binary - binaryVersion, resp, err := s.client.ApplicationVersions.CreateVersion(ctx, app.ID, filename, *opt.Version) + binaryVersion, versionResp, err := s.client.ApplicationVersions.CreateVersion(ctx, app.ID, filename, *opt.Version) if err != nil { - return nil, resp, err + return nil, versionResp, err } if binaryVersion != nil { @@ -197,7 +197,7 @@ func (s *UIExtensionService) CreateExtension(ctx context.Context, application *A } } - return binaryVersion, resp, err + return binaryVersion, versionResp, err } func (s *UIExtensionService) SetActive(ctx context.Context, appID string, binaryID string) (*Application, *Response, error) { From 9527cc7fd60544b3ee8be7a763f718c9e584a052 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Sat, 6 Apr 2024 17:55:20 +0200 Subject: [PATCH 2/2] add unit test --- pkg/c8y/uiExtension.go | 6 +++--- test/c8y_test/uiExtension_test.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/c8y/uiExtension.go b/pkg/c8y/uiExtension.go index 06852286..91766d2e 100644 --- a/pkg/c8y/uiExtension.go +++ b/pkg/c8y/uiExtension.go @@ -177,9 +177,9 @@ func (s *UIExtensionService) CreateExtension(ctx context.Context, application *A } // Upload binary - binaryVersion, versionResp, err := s.client.ApplicationVersions.CreateVersion(ctx, app.ID, filename, *opt.Version) + binaryVersion, binaryVersionResponse, err := s.client.ApplicationVersions.CreateVersion(ctx, app.ID, filename, *opt.Version) if err != nil { - return nil, versionResp, err + return nil, binaryVersionResponse, err } if binaryVersion != nil { @@ -197,7 +197,7 @@ func (s *UIExtensionService) CreateExtension(ctx context.Context, application *A } } - return binaryVersion, versionResp, err + return binaryVersion, binaryVersionResponse, err } func (s *UIExtensionService) SetActive(ctx context.Context, appID string, binaryID string) (*Application, *Response, error) { diff --git a/test/c8y_test/uiExtension_test.go b/test/c8y_test/uiExtension_test.go index fe60198c..3e83f9ad 100644 --- a/test/c8y_test/uiExtension_test.go +++ b/test/c8y_test/uiExtension_test.go @@ -34,7 +34,7 @@ func TestUIExtensionService_CreateExtension(t *testing.T) { app1.ContextPath = app1.Name testingutils.Ok(t, err) - appVersion1, _, err := client.UIExtension.CreateExtension(context.Background(), &app1.Application, file1.Name(), c8y.UpsertOptions{ + appVersion1, resp, err := client.UIExtension.CreateExtension(context.Background(), &app1.Application, file1.Name(), c8y.UpsertOptions{ SkipActivation: false, Version: &c8y.ApplicationVersion{ Version: app1.ManifestFile.Version, @@ -45,6 +45,7 @@ func TestUIExtensionService_CreateExtension(t *testing.T) { client.Application.Delete(context.Background(), appVersion1.Application.ID) }) testingutils.Ok(t, err) + testingutils.Equals(t, "2.4.3", resp.JSON("version").String()) testingutils.Equals(t, "2.4.3", appVersion1.Version) testingutils.Assert(t, len(appVersion1.Tags) == 2, "Tags should be present") testingutils.ContainsString(t, "tag1", appVersion1.Tags)