Skip to content

Commit a26e3fb

Browse files
authored
add missing component tests (#212)
1 parent 21c282b commit a26e3fb

29 files changed

+1837
-239
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ cover:
1313

1414
mock_wire:
1515
@echo "Running wire for component mocks..."
16-
@go run -mod=mod github.com/google/wire/cmd/wire opencsg.com/csghub-server/component
16+
@go run -mod=mod github.com/google/wire/cmd/wire opencsg.com/csghub-server/component/...
1717
@if [ $$? -eq 0 ]; then \
18-
echo "Renaming wire_gen.go to wire_gen_test.go..."; \
18+
echo "Renaming component wire_gen.go to wire_gen_test.go..."; \
1919
mv component/wire_gen.go component/wire_gen_test.go; \
20+
echo "Renaming component/callback wire_gen.go to wire_gen_test.go..."; \
21+
mv component/callback/wire_gen.go component/callback/wire_gen_test.go; \
2022
else \
2123
echo "Wire failed, skipping renaming."; \
2224
fi

api/handler/callback/git_callback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
type GitCallbackHandler struct {
17-
cbc *component.GitCallbackComponent
17+
cbc component.GitCallbackComponent
1818
config *config.Config
1919
}
2020

common/tests/stores.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type MockStores struct {
1414
Model database.ModelStore
1515
SpaceResource database.SpaceResourceStore
1616
Tag database.TagStore
17+
TagRule database.TagRuleStore
1718
Dataset database.DatasetStore
1819
PromptConversation database.PromptConversationStore
1920
PromptPrefix database.PromptPrefixStore
@@ -44,6 +45,9 @@ type MockStores struct {
4445
MultiSync database.MultiSyncStore
4546
File database.FileStore
4647
SSH database.SSHKeyStore
48+
Telemetry database.TelemetryStore
49+
RepoFile database.RepoFileStore
50+
Event database.EventStore
4751
}
4852

4953
func NewMockStores(t interface {
@@ -88,6 +92,10 @@ func NewMockStores(t interface {
8892
MultiSync: mockdb.NewMockMultiSyncStore(t),
8993
File: mockdb.NewMockFileStore(t),
9094
SSH: mockdb.NewMockSSHKeyStore(t),
95+
Telemetry: mockdb.NewMockTelemetryStore(t),
96+
RepoFile: mockdb.NewMockRepoFileStore(t),
97+
Event: mockdb.NewMockEventStore(t),
98+
TagRule: mockdb.NewMockTagRuleStore(t),
9199
}
92100
}
93101

@@ -119,6 +127,10 @@ func (s *MockStores) TagMock() *mockdb.MockTagStore {
119127
return s.Tag.(*mockdb.MockTagStore)
120128
}
121129

130+
func (s *MockStores) TagRuleMock() *mockdb.MockTagRuleStore {
131+
return s.TagRule.(*mockdb.MockTagRuleStore)
132+
}
133+
122134
func (s *MockStores) DatasetMock() *mockdb.MockDatasetStore {
123135
return s.Dataset.(*mockdb.MockDatasetStore)
124136
}
@@ -238,3 +250,15 @@ func (s *MockStores) FileMock() *mockdb.MockFileStore {
238250
func (s *MockStores) SSHMock() *mockdb.MockSSHKeyStore {
239251
return s.SSH.(*mockdb.MockSSHKeyStore)
240252
}
253+
254+
func (s *MockStores) TelemetryMock() *mockdb.MockTelemetryStore {
255+
return s.Telemetry.(*mockdb.MockTelemetryStore)
256+
}
257+
258+
func (s *MockStores) RepoFileMock() *mockdb.MockRepoFileStore {
259+
return s.RepoFile.(*mockdb.MockRepoFileStore)
260+
}
261+
262+
func (s *MockStores) EventMock() *mockdb.MockEventStore {
263+
return s.Event.(*mockdb.MockEventStore)
264+
}

common/types/prompt.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package types
22

3-
import "time"
3+
import (
4+
"time"
5+
)
46

57
type PromptReq struct {
68
Namespace string `json:"namespace"`
@@ -101,3 +103,31 @@ type PromptRes struct {
101103
CanManage bool `json:"can_manage"`
102104
Namespace *Namespace `json:"namespace"`
103105
}
106+
107+
type Prompt struct {
108+
Title string `json:"title" binding:"required"`
109+
Content string `json:"content" binding:"required"`
110+
Language string `json:"language" binding:"required"`
111+
Tags []string `json:"tags"`
112+
Type string `json:"type"` // "text|image|video|audio"
113+
Source string `json:"source"`
114+
Author string `json:"author"`
115+
Time string `json:"time"`
116+
Copyright string `json:"copyright"`
117+
Feedback []string `json:"feedback"`
118+
}
119+
120+
type PromptOutput struct {
121+
Prompt
122+
FilePath string `json:"file_path"`
123+
CanWrite bool `json:"can_write"`
124+
CanManage bool `json:"can_manage"`
125+
}
126+
127+
type CreatePromptReq struct {
128+
Prompt
129+
}
130+
131+
type UpdatePromptReq struct {
132+
Prompt
133+
}

0 commit comments

Comments
 (0)