(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestVersionField(t *testing.T) { |
| 14 | // Test GitHub tool version extraction |
| 15 | t.Run("GitHub version field extraction", func(t *testing.T) { |
| 16 | // Test "version" field with string |
| 17 | githubTool := map[string]any{ |
| 18 | "allowed": []any{"create_issue"}, |
| 19 | "version": "v2.0.0", |
| 20 | } |
| 21 | result := getGitHubDockerImageVersion(githubTool) |
| 22 | if result != "v2.0.0" { |
| 23 | t.Errorf("Expected v2.0.0, got %s", result) |
| 24 | } |
| 25 | |
| 26 | // Test "version" field with integer |
| 27 | githubToolInt := map[string]any{ |
| 28 | "version": 20, |
| 29 | } |
| 30 | result = getGitHubDockerImageVersion(githubToolInt) |
| 31 | if result != "20" { |
| 32 | t.Errorf("Expected 20, got %s", result) |
| 33 | } |
| 34 | |
| 35 | // Test "version" field with uint64 (as YAML parser returns) |
| 36 | githubToolUint64 := map[string]any{ |
| 37 | "version": uint64(42), |
| 38 | } |
| 39 | result = getGitHubDockerImageVersion(githubToolUint64) |
| 40 | if result != "42" { |
| 41 | t.Errorf("Expected 42, got %s", result) |
| 42 | } |
| 43 | |
| 44 | // Test "version" field with float |
| 45 | githubToolFloat := map[string]any{ |
| 46 | "version": 3.11, |
| 47 | } |
| 48 | result = getGitHubDockerImageVersion(githubToolFloat) |
| 49 | if result != "3.11" { |
| 50 | t.Errorf("Expected 3.11, got %s", result) |
| 51 | } |
| 52 | |
| 53 | // Test default value when version field is not present |
| 54 | githubToolDefault := map[string]any{ |
| 55 | "allowed": []any{"create_issue"}, |
| 56 | } |
| 57 | result = getGitHubDockerImageVersion(githubToolDefault) |
| 58 | if result != string(constants.DefaultGitHubMCPServerVersion) { |
| 59 | t.Errorf("Expected default %s, got %s", string(constants.DefaultGitHubMCPServerVersion), result) |
| 60 | } |
| 61 | }) |
| 62 | |
| 63 | // Test MCP parser integration |
| 64 | t.Run("MCP parser version field integration", func(t *testing.T) { |
| 65 | // Test GitHub tool with "version" field |
| 66 | frontmatter := map[string]any{ |
| 67 | "tools": map[string]any{ |
| 68 | "github": map[string]any{ |
| 69 | "allowed": []any{"create_issue"}, |
| 70 | "version": "v2.0.0", |
nothing calls this directly
no test coverage detected