Skip to content

Commit 8af889b

Browse files
authored
test(mcp): refactor helm toolset tests (#333)
Refactor tests to new approach before adding more functionality. Signed-off-by: Marc Nuri <[email protected]>
1 parent 76e2232 commit 8af889b

File tree

5 files changed

+227
-217
lines changed

5 files changed

+227
-217
lines changed

internal/test/test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
package test
22

3+
import (
4+
"os"
5+
"path/filepath"
6+
"runtime"
7+
)
8+
39
func Must[T any](v T, err error) T {
410
if err != nil {
511
panic(err)
612
}
713
return v
814
}
15+
16+
func ReadFile(path ...string) string {
17+
_, file, _, _ := runtime.Caller(1)
18+
filePath := filepath.Join(append([]string{filepath.Dir(file)}, path...)...)
19+
fileBytes := Must(os.ReadFile(filePath))
20+
return string(fileBytes)
21+
}

pkg/mcp/events_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (s *EventsSuite) TestEventsList() {
104104
func (s *EventsSuite) TestEventsListDenied() {
105105
s.Require().NoError(toml.Unmarshal([]byte(`
106106
denied_resources = [ { version = "v1", kind = "Event" } ]
107-
`), s.Cfg), "Expected to parse denied resources config")
107+
`), s.Cfg), "Expected to parse denied resources config")
108108
s.InitMcpClient()
109109
s.Run("events_list (denied)", func() {
110110
toolResult, err := s.CallTool("events_list", map[string]interface{}{})

0 commit comments

Comments
 (0)