Skip to content

Commit 6201a18

Browse files
committed
chore: display source and destination types in connection output
- Add type display in brackets [TYPE] for connection list view - Add 'Type:' field to connection get detailed view - Update tests to verify type fields are displayed correctly
1 parent a7eed65 commit 6201a18

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

pkg/cmd/connection_get.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (cc *connectionGetCmd) runConnectionGetCmd(cmd *cobra.Command, args []strin
8888
fmt.Printf("Source:\n")
8989
fmt.Printf(" Name: %s\n", conn.Source.Name)
9090
fmt.Printf(" ID: %s\n", conn.Source.ID)
91+
fmt.Printf(" Type: %s\n", conn.Source.Type)
9192
fmt.Printf(" URL: %s\n", conn.Source.URL)
9293
fmt.Printf("\n")
9394
}
@@ -97,6 +98,7 @@ func (cc *connectionGetCmd) runConnectionGetCmd(cmd *cobra.Command, args []strin
9798
fmt.Printf("Destination:\n")
9899
fmt.Printf(" Name: %s\n", conn.Destination.Name)
99100
fmt.Printf(" ID: %s\n", conn.Destination.ID)
101+
fmt.Printf(" Type: %s\n", conn.Destination.Type)
100102

101103
if cliPath := conn.Destination.GetCLIPath(); cliPath != nil {
102104
fmt.Printf(" CLI Path: %s\n", *cliPath)

pkg/cmd/connection_list.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,27 @@ func (cc *connectionListCmd) runConnectionListCmd(cmd *cobra.Command, args []str
142142

143143
sourceName := "unknown"
144144
sourceID := "unknown"
145+
sourceType := "unknown"
145146
if conn.Source != nil {
146147
sourceName = conn.Source.Name
147148
sourceID = conn.Source.ID
149+
sourceType = conn.Source.Type
148150
}
149151

150152
destinationName := "unknown"
151153
destinationID := "unknown"
154+
destinationType := "unknown"
152155
if conn.Destination != nil {
153156
destinationName = conn.Destination.Name
154157
destinationID = conn.Destination.ID
158+
destinationType = conn.Destination.Type
155159
}
156160

157161
// Show connection name in color
158162
fmt.Printf("%s\n", color.Green(connectionName))
159163
fmt.Printf(" ID: %s\n", conn.ID)
160-
fmt.Printf(" Source: %s (%s)\n", sourceName, sourceID)
161-
fmt.Printf(" Destination: %s (%s)\n", destinationName, destinationID)
164+
fmt.Printf(" Source: %s (%s) [%s]\n", sourceName, sourceID, sourceType)
165+
fmt.Printf(" Destination: %s (%s) [%s]\n", destinationName, destinationID, destinationType)
162166

163167
if conn.DisabledAt != nil {
164168
fmt.Printf(" Status: %s\n", color.Red("disabled"))

test/acceptance/connection_list_test.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,30 @@ func TestConnectionListFilters(t *testing.T) {
249249
}
250250

251251
cli := NewCLIRunner(t)
252+
timestamp := generateTimestamp()
253+
254+
connName := "test-human-output-" + timestamp
255+
sourceName := "test-human-src-" + timestamp
256+
destName := "test-human-dst-" + timestamp
257+
258+
// Create a connection to test output format
259+
var conn Connection
260+
err := cli.RunJSON(&conn,
261+
"connection", "create",
262+
"--name", connName,
263+
"--source-name", sourceName,
264+
"--source-type", "WEBHOOK",
265+
"--destination-name", destName,
266+
"--destination-type", "CLI",
267+
"--destination-cli-path", "/webhooks",
268+
)
269+
require.NoError(t, err, "Should create connection")
270+
require.NotEmpty(t, conn.ID, "Connection should have an ID")
271+
272+
// Cleanup
273+
t.Cleanup(func() {
274+
deleteConnection(t, cli, conn.ID)
275+
})
252276

253277
// List without --output json to get human-readable format
254278
stdout := cli.RunExpectSuccess("connection", "list")
@@ -258,6 +282,14 @@ func TestConnectionListFilters(t *testing.T) {
258282
strings.Contains(stdout, "connection") || strings.Contains(stdout, "No connections found"),
259283
"Should produce human-readable output")
260284

261-
t.Logf("Successfully tested human-readable output format")
285+
// Verify source and destination types are displayed
286+
assert.True(t,
287+
strings.Contains(stdout, "[WEBHOOK]") || strings.Contains(stdout, "[webhook]"),
288+
"Should display source type in output")
289+
assert.True(t,
290+
strings.Contains(stdout, "[CLI]") || strings.Contains(stdout, "[cli]"),
291+
"Should display destination type in output")
292+
293+
t.Logf("Successfully tested human-readable output format with type display")
262294
})
263295
}

test/acceptance/connection_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,23 @@ func TestConnectionCreateAndDelete(t *testing.T) {
4141
deleteConnection(t, cli, connID)
4242
})
4343

44-
// Verify the connection was created by getting it
44+
// Verify the connection was created by getting it (JSON output)
4545
var conn Connection
4646
err := cli.RunJSON(&conn, "connection", "get", connID)
4747
require.NoError(t, err, "Should be able to get the created connection")
4848
assert.Equal(t, connID, conn.ID, "Retrieved connection ID should match")
4949
assert.NotEmpty(t, conn.Name, "Connection should have a name")
5050
assert.NotEmpty(t, conn.Source.Name, "Connection should have a source")
51+
assert.NotEmpty(t, conn.Source.Type, "Connection source should have a type")
5152
assert.NotEmpty(t, conn.Destination.Name, "Connection should have a destination")
53+
assert.NotEmpty(t, conn.Destination.Type, "Connection destination should have a type")
54+
55+
// Verify human-readable output includes type information
56+
stdout := cli.RunExpectSuccess("connection", "get", connID)
57+
assert.Contains(t, stdout, "Type:", "Human-readable output should include 'Type:' label")
58+
assert.True(t,
59+
strings.Contains(stdout, conn.Source.Type) && strings.Contains(stdout, conn.Destination.Type),
60+
"Human-readable output should display both source and destination types")
5261

5362
t.Logf("Successfully created and retrieved connection: %s", conn.Name)
5463
}

0 commit comments

Comments
 (0)