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

Function Test_parseErrorResponse

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

Source from the content-addressed store, hash-verified

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