Skip to content

Commit

Permalink
add missing component tests (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiling-J authored Dec 16, 2024
1 parent 21c282b commit a26e3fb
Show file tree
Hide file tree
Showing 29 changed files with 1,837 additions and 239 deletions.
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
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
24 changes: 24 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 @@ -44,6 +45,9 @@ type MockStores struct {
MultiSync database.MultiSyncStore
File database.FileStore
SSH database.SSHKeyStore
Telemetry database.TelemetryStore
RepoFile database.RepoFileStore
Event database.EventStore
}

func NewMockStores(t interface {
Expand Down Expand Up @@ -88,6 +92,10 @@ func NewMockStores(t interface {
MultiSync: mockdb.NewMockMultiSyncStore(t),
File: mockdb.NewMockFileStore(t),
SSH: mockdb.NewMockSSHKeyStore(t),
Telemetry: mockdb.NewMockTelemetryStore(t),
RepoFile: mockdb.NewMockRepoFileStore(t),
Event: mockdb.NewMockEventStore(t),
TagRule: mockdb.NewMockTagRuleStore(t),
}
}

Expand Down Expand Up @@ -119,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 Expand Up @@ -238,3 +250,15 @@ func (s *MockStores) FileMock() *mockdb.MockFileStore {
func (s *MockStores) SSHMock() *mockdb.MockSSHKeyStore {
return s.SSH.(*mockdb.MockSSHKeyStore)
}

func (s *MockStores) TelemetryMock() *mockdb.MockTelemetryStore {
return s.Telemetry.(*mockdb.MockTelemetryStore)
}

func (s *MockStores) RepoFileMock() *mockdb.MockRepoFileStore {
return s.RepoFile.(*mockdb.MockRepoFileStore)
}

func (s *MockStores) EventMock() *mockdb.MockEventStore {
return s.Event.(*mockdb.MockEventStore)
}
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 a26e3fb

Please sign in to comment.