Skip to content

Commit fcce893

Browse files
committed
Add compatibility tests for pseudo-column aliases
1 parent 3c1e75c commit fcce893

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

internal/commands/card_test.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,44 @@ func TestCardList(t *testing.T) {
8888
}
8989
})
9090

91+
t.Run("supports legacy pseudo column aliases for listing", func(t *testing.T) {
92+
t.Run("not_now", func(t *testing.T) {
93+
mock := NewMockClient()
94+
mock.GetWithPaginationResponse = &client.APIResponse{StatusCode: 200, Data: []any{}}
95+
96+
SetTestModeWithSDK(mock)
97+
SetTestConfig("token", "account", "https://api.example.com")
98+
defer resetTest()
99+
100+
cardListColumn = "not_now"
101+
err := cardListCmd.RunE(cardListCmd, []string{})
102+
cardListColumn = ""
103+
104+
assertExitCode(t, err, 0)
105+
if mock.GetWithPaginationCalls[0].Path != "/cards.json?indexed_by=not_now" {
106+
t.Errorf("expected legacy alias to map to indexed_by=not_now, got '%s'", mock.GetWithPaginationCalls[0].Path)
107+
}
108+
})
109+
110+
t.Run("triage", func(t *testing.T) {
111+
mock := NewMockClient()
112+
mock.GetWithPaginationResponse = &client.APIResponse{StatusCode: 200, Data: []any{}}
113+
114+
SetTestModeWithSDK(mock)
115+
SetTestConfig("token", "account", "https://api.example.com")
116+
defer resetTest()
117+
118+
cardListColumn = "triage"
119+
err := cardListCmd.RunE(cardListCmd, []string{})
120+
cardListColumn = ""
121+
122+
assertExitCode(t, err, 0)
123+
if mock.GetWithPaginationCalls[0].Path != "/cards.json?indexed_by=maybe" {
124+
t.Errorf("expected legacy alias to map to indexed_by=maybe, got '%s'", mock.GetWithPaginationCalls[0].Path)
125+
}
126+
})
127+
})
128+
91129
t.Run("filters by real column server-side without client-side filtering", func(t *testing.T) {
92130
mock := NewMockClient()
93131
mock.GetWithPaginationResponse = &client.APIResponse{
@@ -838,6 +876,24 @@ func TestCardColumn(t *testing.T) {
838876
}
839877
})
840878

879+
t.Run("not_now alias", func(t *testing.T) {
880+
mock := NewMockClient()
881+
mock.PostResponse = &client.APIResponse{StatusCode: 200, Data: map[string]any{}}
882+
883+
SetTestModeWithSDK(mock)
884+
SetTestConfig("token", "account", "https://api.example.com")
885+
defer resetTest()
886+
887+
cardColumnColumn = "not_now"
888+
err := cardColumnCmd.RunE(cardColumnCmd, []string{"42"})
889+
cardColumnColumn = ""
890+
891+
assertExitCode(t, err, 0)
892+
if len(mock.PostCalls) != 1 || mock.PostCalls[0].Path != "/cards/42/not_now.json" {
893+
t.Errorf("expected post '/cards/42/not_now.json', got %+v", mock.PostCalls)
894+
}
895+
})
896+
841897
t.Run("maybe", func(t *testing.T) {
842898
mock := NewMockClient()
843899
mock.DeleteResponse = &client.APIResponse{StatusCode: 200, Data: map[string]any{}}
@@ -856,6 +912,24 @@ func TestCardColumn(t *testing.T) {
856912
}
857913
})
858914

915+
t.Run("triage alias", func(t *testing.T) {
916+
mock := NewMockClient()
917+
mock.DeleteResponse = &client.APIResponse{StatusCode: 200, Data: map[string]any{}}
918+
919+
SetTestModeWithSDK(mock)
920+
SetTestConfig("token", "account", "https://api.example.com")
921+
defer resetTest()
922+
923+
cardColumnColumn = "triage"
924+
err := cardColumnCmd.RunE(cardColumnCmd, []string{"42"})
925+
cardColumnColumn = ""
926+
927+
assertExitCode(t, err, 0)
928+
if len(mock.DeleteCalls) != 1 || mock.DeleteCalls[0].Path != "/cards/42/triage.json" {
929+
t.Errorf("expected delete '/cards/42/triage.json', got %+v", mock.DeleteCalls)
930+
}
931+
})
932+
859933
t.Run("done", func(t *testing.T) {
860934
mock := NewMockClient()
861935
mock.PostResponse = &client.APIResponse{StatusCode: 200, Data: map[string]any{}}

0 commit comments

Comments
 (0)