mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 22:55:54 +08:00
fix: updated unit tests and mocks
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
5e0d6110b5
commit
ea1f4e8253
@ -1,7 +1,8 @@
|
|||||||
package impltracefunnel
|
package tracefunneltest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/SigNoz/signoz/pkg/modules/tracefunnel/impltracefunnel"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -43,28 +44,28 @@ func (m *MockStore) Delete(ctx context.Context, uuid valuer.UUID) error {
|
|||||||
|
|
||||||
func TestModule_Create(t *testing.T) {
|
func TestModule_Create(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
timestamp := time.Now().UnixMilli()
|
timestamp := time.Now().UnixMilli()
|
||||||
name := "test-funnel"
|
name := "test-funnel"
|
||||||
userID := "user-123"
|
userID := valuer.GenerateUUID()
|
||||||
orgID := valuer.GenerateUUID().String()
|
orgID := valuer.GenerateUUID().String()
|
||||||
|
|
||||||
mockStore.On("Create", ctx, mock.MatchedBy(func(f *traceFunnels.Funnel) bool {
|
mockStore.On("Create", ctx, mock.MatchedBy(func(f *traceFunnels.Funnel) bool {
|
||||||
return f.Name == name &&
|
return f.Name == name &&
|
||||||
f.CreatedBy == userID &&
|
f.CreatedBy == userID.String() &&
|
||||||
f.OrgID.String() == orgID &&
|
f.OrgID.String() == orgID &&
|
||||||
f.CreatedByUser != nil &&
|
f.CreatedByUser != nil &&
|
||||||
f.CreatedByUser.ID == userID &&
|
f.CreatedByUser.ID == userID &&
|
||||||
f.CreatedAt.UnixNano()/1000000 == timestamp
|
f.CreatedAt.UnixNano()/1000000 == timestamp
|
||||||
})).Return(nil)
|
})).Return(nil)
|
||||||
|
|
||||||
funnel, err := module.Create(ctx, timestamp, name, userID, orgID)
|
funnel, err := module.Create(ctx, timestamp, name, userID.String(), orgID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, funnel)
|
assert.NotNil(t, funnel)
|
||||||
assert.Equal(t, name, funnel.Name)
|
assert.Equal(t, name, funnel.Name)
|
||||||
assert.Equal(t, userID, funnel.CreatedBy)
|
assert.Equal(t, userID.String(), funnel.CreatedBy)
|
||||||
assert.Equal(t, orgID, funnel.OrgID.String())
|
assert.Equal(t, orgID, funnel.OrgID.String())
|
||||||
assert.NotNil(t, funnel.CreatedByUser)
|
assert.NotNil(t, funnel.CreatedByUser)
|
||||||
assert.Equal(t, userID, funnel.CreatedByUser.ID)
|
assert.Equal(t, userID, funnel.CreatedByUser.ID)
|
||||||
@ -74,7 +75,7 @@ func TestModule_Create(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_Get(t *testing.T) {
|
func TestModule_Get(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
funnelID := valuer.GenerateUUID().String()
|
funnelID := valuer.GenerateUUID().String()
|
||||||
@ -95,7 +96,7 @@ func TestModule_Get(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_Update(t *testing.T) {
|
func TestModule_Update(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
userID := "user-123"
|
userID := "user-123"
|
||||||
@ -116,7 +117,7 @@ func TestModule_Update(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_List(t *testing.T) {
|
func TestModule_List(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
orgID := valuer.GenerateUUID().String()
|
orgID := valuer.GenerateUUID().String()
|
||||||
@ -148,7 +149,7 @@ func TestModule_List(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_Delete(t *testing.T) {
|
func TestModule_Delete(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
funnelID := valuer.GenerateUUID().String()
|
funnelID := valuer.GenerateUUID().String()
|
||||||
@ -163,7 +164,7 @@ func TestModule_Delete(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_Save(t *testing.T) {
|
func TestModule_Save(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
userID := "user-123"
|
userID := "user-123"
|
||||||
@ -186,7 +187,7 @@ func TestModule_Save(t *testing.T) {
|
|||||||
|
|
||||||
func TestModule_GetFunnelMetadata(t *testing.T) {
|
func TestModule_GetFunnelMetadata(t *testing.T) {
|
||||||
mockStore := new(MockStore)
|
mockStore := new(MockStore)
|
||||||
module := NewModule(mockStore)
|
module := impltracefunnel.NewModule(mockStore)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
funnelID := valuer.GenerateUUID().String()
|
funnelID := valuer.GenerateUUID().String()
|
Loading…
x
Reference in New Issue
Block a user