Skip to content

Commit 427a68f

Browse files
authored
Add error detail tests for canvases methods
Added tests for error handling in canvases.create and canvases.edit methods.
1 parent 00f3bd7 commit 427a68f

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

slack-api-client/src/test/java/test_with_remote_apis/methods/canvases_Test.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import org.junit.Test;
2323

2424
import java.util.Arrays;
25+
import java.util.Collections;
2526
import java.util.List;
2627

27-
import static org.hamcrest.CoreMatchers.is;
28-
import static org.hamcrest.CoreMatchers.nullValue;
28+
import static org.hamcrest.CoreMatchers.*;
2929
import static org.hamcrest.MatcherAssert.assertThat;
3030

3131
@Slf4j
@@ -160,4 +160,34 @@ public void standalone_canvases_error() throws Exception {
160160
);
161161
assertThat(creation.getError(), is("invalid_arguments"));
162162
}
163+
164+
@Test
165+
public void error_detail() throws Exception {
166+
MethodsClient client = slack.methods(botToken);
167+
// canvases.create
168+
{
169+
CanvasesCreateResponse response = client.canvasesCreate(r -> r
170+
.title("test")
171+
.documentContent(CanvasDocumentContent.builder()
172+
.markdown("test")
173+
.type("invalid")
174+
.build())
175+
);
176+
assertThat(response.isOk(), is(false));
177+
assertThat(response.getError(), is("invalid_arguments"));
178+
assertThat(response.getDetail(), is(notNullValue()));
179+
}
180+
// canvases.edit
181+
{
182+
CanvasesEditResponse response = client.canvasesEdit(r -> r
183+
.canvasId("F123")
184+
.changes(Collections.singletonList(CanvasDocumentChange.builder()
185+
.documentContent(CanvasDocumentContent.builder().markdown("foo").type("invalid").build())
186+
.build()))
187+
);
188+
assertThat(response.isOk(), is(false));
189+
assertThat(response.getError(), is("invalid_arguments"));
190+
assertThat(response.getDetail(), is(notNullValue()));
191+
}
192+
}
163193
}

0 commit comments

Comments
 (0)