MSP-6673 Fix tests
This commit is contained in:
1 parent
04b5eef606
commit
8da4fcb819
3 files changed
+35
-27
No files matched your search
+26
-16
@@ -70,10 +70,14 @@ func (s *ApplicationSuite) TestGetAllApplications() {
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_HappyPath() {
|
||||
result := domain.ApplicationWithTokens{}
|
||||
apiReq := fake.It[domain.CreateApplicationRequest]()
|
||||
apiReq.Type = domain.ApplicationSystemType
|
||||
appGroup := s.createAppGroup()
|
||||
apiReq.ApplicationGroupId = appGroup.Id
|
||||
|
||||
apiReq := domain.CreateApplicationRequest{
|
||||
Id: 1,
|
||||
Name: fake.It[string](),
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: appGroup.Id,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
JsonRequestBody(apiReq).
|
||||
@@ -99,8 +103,12 @@ func (s *ApplicationSuite) TestCreate_HappyPath() {
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_AppGroupNotFound() {
|
||||
apiReq := fake.It[domain.CreateApplicationRequest]()
|
||||
apiReq.Type = domain.ApplicationSystemType
|
||||
apiReq := domain.CreateApplicationRequest{
|
||||
Id: 1,
|
||||
Name: fake.It[string](),
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: 1,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
JsonRequestBody(apiReq).
|
||||
@@ -111,13 +119,14 @@ func (s *ApplicationSuite) TestCreate_AppGroupNotFound() {
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_ApplicationNameNotUniqueInAppGroup() {
|
||||
apiReq := fake.It[domain.CreateApplicationRequest]()
|
||||
apiReq.Type = domain.ApplicationSystemType
|
||||
|
||||
inserted := s.insertApps(1)
|
||||
|
||||
apiReq.ApplicationGroupId = inserted[0].ServiceId
|
||||
apiReq.Name = inserted[0].Name
|
||||
apiReq := domain.CreateApplicationRequest{
|
||||
Id: inserted[0].Id + 1,
|
||||
Name: inserted[0].Name,
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: inserted[0].ServiceId,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
JsonRequestBody(apiReq).
|
||||
@@ -128,13 +137,14 @@ func (s *ApplicationSuite) TestCreate_ApplicationNameNotUniqueInAppGroup() {
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) TestCreate_ApplicationIdNotUnique() {
|
||||
apiReq := fake.It[domain.CreateApplicationRequest]()
|
||||
apiReq.Type = "SYSTEM"
|
||||
appGroup := s.createAppGroup()
|
||||
apiReq.ApplicationGroupId = appGroup.Id
|
||||
|
||||
inserted := s.insertApps(1)
|
||||
apiReq.Id = inserted[0].Id
|
||||
|
||||
apiReq := domain.CreateApplicationRequest{
|
||||
Id: inserted[0].Id,
|
||||
Name: inserted[0].Name,
|
||||
Type: domain.ApplicationSystemType,
|
||||
ApplicationGroupId: inserted[0].ServiceId,
|
||||
}
|
||||
|
||||
err := s.api.Invoke("system/application/create_application").
|
||||
JsonRequestBody(apiReq).
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/txix-open/isp-kit/dbx"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
@@ -45,9 +44,9 @@ func (s *BaselineSuite) SetupSuite() {
|
||||
}
|
||||
|
||||
func (s *BaselineSuite) TestBaselineSuccess() {
|
||||
err := s.baseline.Do(context.Background())
|
||||
err := s.baseline.Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = s.baseline.Do(context.Background())
|
||||
err = s.baseline.Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -64,7 +63,7 @@ func (s *SecureSuite) TestAuthenticate_Success() {
|
||||
Token: "test_token_success",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
@@ -85,7 +84,7 @@ func (s *SecureSuite) TestAuthenticate_NotFound() {
|
||||
Token: "test_token_not_found",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthenticateResponse{
|
||||
Authenticated: false,
|
||||
@@ -105,7 +104,7 @@ func (s *SecureSuite) TestAuthenticate_NotExpired() {
|
||||
Token: "test_token_not_expired",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
@@ -130,7 +129,7 @@ func (s *SecureSuite) TestAuthenticate_Expired() {
|
||||
Token: "test_token_expired",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthenticateResponse{
|
||||
Authenticated: false,
|
||||
@@ -153,7 +152,7 @@ func (s *SecureSuite) TestAuthorize_Success_True() {
|
||||
Endpoint: "endpoint/available",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthorizeResponse{
|
||||
Authorized: true,
|
||||
@@ -174,7 +173,7 @@ func (s *SecureSuite) TestAuthorize_Success_False() {
|
||||
Endpoint: "endpoint/not_available",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthorizeResponse{
|
||||
Authorized: false,
|
||||
@@ -189,7 +188,7 @@ func (s *SecureSuite) TestAuthorize_NotFound() {
|
||||
Endpoint: "endpoint/not_found",
|
||||
}).
|
||||
JsonResponseBody(&result).
|
||||
Do(context.Background())
|
||||
Do(s.T().Context())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(domain.AuthorizeResponse{
|
||||
Authorized: false,
|
||||
|
||||
Reference in new issue
Block a user