Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pkg/connectors/microcks_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,26 @@ func (c *microcksClient) CreateTestResult(serviceID string, testEndpoint string,
}
defer resp.Body.Close()

// Dump response if verbose required.
config.DumpResponseIfRequired("Microcks for creating test", resp, true)

body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err.Error())
return "", fmt.Errorf("failed to read response body: %w", err)
}

// Check HTTP status before attempting to parse.
if resp.StatusCode != 201 {
return "", fmt.Errorf("microcks returned HTTP %d: %s (is the service '%s' registered?)", resp.StatusCode, strings.TrimSpace(string(body)), serviceID)
}

var createTestResp map[string]interface{}
if err := json.Unmarshal(body, &createTestResp); err != nil {
panic(err)
return "", fmt.Errorf("failed to parse test creation response: %w", err)
}

testID := createTestResp["id"].(string)
return testID, err
testID, ok := createTestResp["id"].(string)
if !ok || testID == "" {
return "", fmt.Errorf("microcks response missing 'id' field")
}
return testID, nil
}

func (c *microcksClient) GetTestResult(testResultID string) (*TestResultSummary, error) {
Expand Down