From 692c4e491f0d5e8000d602c244b471755627e69b Mon Sep 17 00:00:00 2001 From: Dipjyoti Metia Date: Wed, 4 Sep 2024 22:59:35 +1000 Subject: [PATCH] update --- cmd/cmd.go | 1 - pkg/atlassian/confluence/client.go | 2 +- pkg/atlassian/jira/issues.go | 1 - pkg/commands/genai.go | 46 ------------------------------ pkg/commands/genai_test.go | 38 ------------------------ 5 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 pkg/commands/genai_test.go diff --git a/cmd/cmd.go b/cmd/cmd.go index 7ccc205..1271c49 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -29,7 +29,6 @@ func init() { rootCmd.AddCommand(commands.GenerateTestScenarios()) rootCmd.AddCommand(commands.SpecAnalyzer()) rootCmd.AddCommand(commands.GrpcCurlGenerator()) - rootCmd.AddCommand(commands.ReadConfluenceJira()) // P8106 } func Execute() { diff --git a/pkg/atlassian/confluence/client.go b/pkg/atlassian/confluence/client.go index cf2957a..a1138d8 100644 --- a/pkg/atlassian/confluence/client.go +++ b/pkg/atlassian/confluence/client.go @@ -34,7 +34,7 @@ func New(ctx context.Context) *client { } func (c *client) GetPages() ([]string, error) { - pages, _, err := c.Client.Page.Gets(context.Background(), "", "", "", "", 0, 0) + pages, _, err := c.Client.Page.Gets(context.Background(), nil, "", 0) if err != nil { return nil, err } diff --git a/pkg/atlassian/jira/issues.go b/pkg/atlassian/jira/issues.go index b4d5812..725309a 100644 --- a/pkg/atlassian/jira/issues.go +++ b/pkg/atlassian/jira/issues.go @@ -12,5 +12,4 @@ func (c *client) GetIssues() { log.Fatal(err) } fmt.Println(issues.Fields.Description) - } diff --git a/pkg/commands/genai.go b/pkg/commands/genai.go index cd9fc89..e333a81 100644 --- a/pkg/commands/genai.go +++ b/pkg/commands/genai.go @@ -10,8 +10,6 @@ import ( "github.com/dipjyotimetia/jarvis/pkg/engine/files" "github.com/dipjyotimetia/jarvis/pkg/engine/gemini" "github.com/dipjyotimetia/jarvis/pkg/engine/prompt" - "github.com/dipjyotimetia/jarvis/pkg/atlassian/confluence" - "github.com/dipjyotimetia/jarvis/pkg/atlassian/jira" "github.com/spf13/cobra" ) @@ -132,47 +130,3 @@ func GenerateTestScenarios() *cobra.Command { setGenerateScenariosFlag(cmd) return cmd } - -func ReadConfluenceJira() *cobra.Command { - cmd := &cobra.Command{ - Use: "read-confluence-jira", - Aliases: []string{"rcj"}, - Short: "read-confluence-jira is for reading from Confluence and Jira and suggesting test cases.", - Long: `read-confluence-jira is for reading from Confluence and Jira and suggesting test cases using Google Gemini`, - RunE: func(cmd *cobra.Command, args []string) error { - ctx := context.Background() - - // Initialize Confluence client - confluenceClient := confluence.New(ctx) - pages, err := confluenceClient.GetPages() - if err != nil { - return fmt.Errorf("failed to get pages from Confluence: %w", err) - } - - // Initialize Jira client - jiraClient := jira.New(ctx) - issues, err := jiraClient.GetIssues() - if err != nil { - return fmt.Errorf("failed to get issues from Jira: %w", err) - } - - // Initialize Gemini client - ai, err := gemini.New(ctx) - if err != nil { - return fmt.Errorf("failed to create Gemini engine: %w", err) - } - - // Combine pages and issues into a single input for Gemini - input := append(pages, issues...) - - // Generate test cases using Gemini - err = ai.GenerateTextStream(ctx, input, "confluence-jira") - if err != nil { - return fmt.Errorf("failed to generate test cases: %w", err) - } - - return nil - }, - } - return cmd -} diff --git a/pkg/commands/genai_test.go b/pkg/commands/genai_test.go deleted file mode 100644 index f3ffe6e..0000000 --- a/pkg/commands/genai_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package commands - -import ( - "context" - "testing" - - "github.com/dipjyotimetia/jarvis/pkg/atlassian/confluence" - "github.com/dipjyotimetia/jarvis/pkg/atlassian/jira" - "github.com/dipjyotimetia/jarvis/pkg/engine/gemini" - "github.com/stretchr/testify/assert" -) - -func TestReadConfluenceJira(t *testing.T) { - ctx := context.Background() - - // Mock Confluence client - confluenceClient := &confluence.MockClient{} - confluenceClient.On("GetPages").Return([]string{"Page1", "Page2"}, nil) - - // Mock Jira client - jiraClient := &jira.MockClient{} - jiraClient.On("GetIssues").Return([]string{"Issue1", "Issue2"}, nil) - - // Mock Gemini client - geminiClient := &gemini.MockClient{} - geminiClient.On("GenerateTextStream", ctx, []string{"Page1", "Page2", "Issue1", "Issue2"}, "confluence-jira").Return(nil) - - // Call the function - err := ReadConfluenceJira(ctx, confluenceClient, jiraClient, geminiClient) - - // Assert no error - assert.NoError(t, err) - - // Assert that the mocks were called - confluenceClient.AssertCalled(t, "GetPages") - jiraClient.AssertCalled(t, "GetIssues") - geminiClient.AssertCalled(t, "GenerateTextStream", ctx, []string{"Page1", "Page2", "Issue1", "Issue2"}, "confluence-jira") -}