Skip to content

Commit

Permalink
Merge branch 'feature/component_tests' into 'main'
Browse files Browse the repository at this point in the history
Add component/callback tests

See merge request product/starhub/starhub-server!724
  • Loading branch information
yiling.ji authored and Yiling-J committed Dec 16, 2024
1 parent 0b7ce18 commit 5034ffa
Show file tree
Hide file tree
Showing 12 changed files with 586 additions and 90 deletions.
4 changes: 4 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ packages:
SpaceComponent:
RuntimeArchitectureComponent:
SensitiveComponent:
opencsg.com/csghub-server/component/callback:
config:
interfaces:
SyncVersionGenerator:
opencsg.com/csghub-server/user/component:
config:
interfaces:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ cover:

mock_wire:
@echo "Running wire for component mocks..."
@go run -mod=mod github.com/google/wire/cmd/wire opencsg.com/csghub-server/component
@go run -mod=mod github.com/google/wire/cmd/wire opencsg.com/csghub-server/component/...
@if [ $$? -eq 0 ]; then \
echo "Renaming wire_gen.go to wire_gen_test.go..."; \
echo "Renaming component wire_gen.go to wire_gen_test.go..."; \
mv component/wire_gen.go component/wire_gen_test.go; \
echo "Renaming component/callback wire_gen.go to wire_gen_test.go..."; \
mv component/callback/wire_gen.go component/callback/wire_gen_test.go; \
else \
echo "Wire failed, skipping renaming."; \
fi
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/handler/callback/git_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type GitCallbackHandler struct {
cbc *component.GitCallbackComponent
cbc component.GitCallbackComponent
config *config.Config
}

Expand Down
6 changes: 6 additions & 0 deletions common/tests/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type MockStores struct {
Model database.ModelStore
SpaceResource database.SpaceResourceStore
Tag database.TagStore
TagRule database.TagRuleStore
Dataset database.DatasetStore
PromptConversation database.PromptConversationStore
PromptPrefix database.PromptPrefixStore
Expand Down Expand Up @@ -94,6 +95,7 @@ func NewMockStores(t interface {
Telemetry: mockdb.NewMockTelemetryStore(t),
RepoFile: mockdb.NewMockRepoFileStore(t),
Event: mockdb.NewMockEventStore(t),
TagRule: mockdb.NewMockTagRuleStore(t),
}
}

Expand Down Expand Up @@ -125,6 +127,10 @@ func (s *MockStores) TagMock() *mockdb.MockTagStore {
return s.Tag.(*mockdb.MockTagStore)
}

func (s *MockStores) TagRuleMock() *mockdb.MockTagRuleStore {
return s.TagRule.(*mockdb.MockTagRuleStore)
}

func (s *MockStores) DatasetMock() *mockdb.MockDatasetStore {
return s.Dataset.(*mockdb.MockDatasetStore)
}
Expand Down
32 changes: 31 additions & 1 deletion common/types/prompt.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types

import "time"
import (
"time"
)

type PromptReq struct {
Namespace string `json:"namespace"`
Expand Down Expand Up @@ -101,3 +103,31 @@ type PromptRes struct {
CanManage bool `json:"can_manage"`
Namespace *Namespace `json:"namespace"`
}

type Prompt struct {
Title string `json:"title" binding:"required"`
Content string `json:"content" binding:"required"`
Language string `json:"language" binding:"required"`
Tags []string `json:"tags"`
Type string `json:"type"` // "text|image|video|audio"
Source string `json:"source"`
Author string `json:"author"`
Time string `json:"time"`
Copyright string `json:"copyright"`
Feedback []string `json:"feedback"`
}

type PromptOutput struct {
Prompt
FilePath string `json:"file_path"`
CanWrite bool `json:"can_write"`
CanManage bool `json:"can_manage"`
}

type CreatePromptReq struct {
Prompt
}

type UpdatePromptReq struct {
Prompt
}
Loading

0 comments on commit 5034ffa

Please sign in to comment.