MCPcopy Create free account
hub / github.com/cli/cli / Test_parseErrorResponse

Function Test_parseErrorResponse

pkg/cmd/api/api_test.go:1876–1956  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1874}
1875
1876func Test_parseErrorResponse(t *testing.T) {
1877 type args struct {
1878 input string
1879 statusCode int
1880 }
1881 tests := []struct {
1882 name string
1883 args args
1884 wantErrMsg string
1885 wantErr bool
1886 }{
1887 {
1888 name: "no error",
1889 args: args{
1890 input: `{}`,
1891 statusCode: 500,
1892 },
1893 wantErrMsg: "",
1894 wantErr: false,
1895 },
1896 {
1897 name: "nil errors",
1898 args: args{
1899 input: `{"errors":null}`,
1900 statusCode: 500,
1901 },
1902 wantErrMsg: "",
1903 wantErr: false,
1904 },
1905 {
1906 name: "simple error",
1907 args: args{
1908 input: `{"message": "OH NOES"}`,
1909 statusCode: 500,
1910 },
1911 wantErrMsg: "OH NOES (HTTP 500)",
1912 wantErr: false,
1913 },
1914 {
1915 name: "errors string",
1916 args: args{
1917 input: `{"message": "Conflict", "errors": "Some description"}`,
1918 statusCode: 409,
1919 },
1920 wantErrMsg: "Some description (Conflict)",
1921 wantErr: false,
1922 },
1923 {
1924 name: "errors array of strings",
1925 args: args{
1926 input: `{"errors": ["fail1", "asplode2"]}`,
1927 statusCode: 500,
1928 },
1929 wantErrMsg: "fail1\nasplode2",
1930 wantErr: false,
1931 },
1932 {
1933 name: "errors array of objects",

Callers

nothing calls this directly

Calls 3

parseErrorResponseFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected