-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/component_tests' into 'main'
Add missing component tests See merge request product/starhub/starhub-server!719
- Loading branch information
Showing
21 changed files
with
1,388 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package component | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"opencsg.com/csghub-server/common/types" | ||
) | ||
|
||
func TestClusterComponent_Index(t *testing.T) { | ||
ctx := context.TODO() | ||
cc := initializeTestClusterComponent(ctx, t) | ||
|
||
cc.mocks.deployer.EXPECT().ListCluster(ctx).Return(nil, nil) | ||
|
||
data, err := cc.Index(ctx) | ||
require.Nil(t, err) | ||
require.Equal(t, []types.ClusterRes([]types.ClusterRes(nil)), data) | ||
} | ||
|
||
func TestClusterComponent_GetClusterById(t *testing.T) { | ||
ctx := context.TODO() | ||
cc := initializeTestClusterComponent(ctx, t) | ||
|
||
cc.mocks.deployer.EXPECT().GetClusterById(ctx, "c1").Return(nil, nil) | ||
|
||
data, err := cc.GetClusterById(ctx, "c1") | ||
require.Nil(t, err) | ||
require.Equal(t, (*types.ClusterRes)(nil), data) | ||
} | ||
|
||
func TestClusterComponent_Update(t *testing.T) { | ||
ctx := context.TODO() | ||
cc := initializeTestClusterComponent(ctx, t) | ||
|
||
cc.mocks.deployer.EXPECT().UpdateCluster(ctx, types.ClusterRequest{}).Return(nil, nil) | ||
|
||
data, err := cc.Update(ctx, types.ClusterRequest{}) | ||
require.Nil(t, err) | ||
require.Equal(t, (*types.UpdateClusterResponse)(nil), data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package component | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"opencsg.com/csghub-server/builder/store/database" | ||
"opencsg.com/csghub-server/common/types" | ||
) | ||
|
||
func TestEventComponent_NewEvent(t *testing.T) { | ||
ctx := context.TODO() | ||
ec := initializeTestEventComponent(ctx, t) | ||
|
||
ec.mocks.stores.EventMock().EXPECT().BatchSave(ctx, []database.Event{ | ||
{EventID: "e1"}, | ||
}).Return(nil) | ||
|
||
err := ec.NewEvents(ctx, []types.Event{{ID: "e1"}}) | ||
require.Nil(t, err) | ||
} |
Oops, something went wrong.