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

Function Test_parseErrorResponse

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

Source from the content-addressed store, hash-verified

1804}
1805
1806func Test_parseErrorResponse(t *testing.T) {
1807 type args struct {
1808 input string
1809 statusCode int
1810 }
1811 tests := []struct {
1812 name string
1813 args args
1814 wantErrMsg string
1815 wantErr bool
1816 }{
1817 {
1818 name: "no error",
1819 args: args{
1820 input: `{}`,
1821 statusCode: 500,
1822 },
1823 wantErrMsg: "",
1824 wantErr: false,
1825 },
1826 {
1827 name: "nil errors",
1828 args: args{
1829 input: `{"errors":null}`,
1830 statusCode: 500,
1831 },
1832 wantErrMsg: "",
1833 wantErr: false,
1834 },
1835 {
1836 name: "simple error",
1837 args: args{
1838 input: `{"message": "OH NOES"}`,
1839 statusCode: 500,
1840 },
1841 wantErrMsg: "OH NOES (HTTP 500)",
1842 wantErr: false,
1843 },
1844 {
1845 name: "errors string",
1846 args: args{
1847 input: `{"message": "Conflict", "errors": "Some description"}`,
1848 statusCode: 409,
1849 },
1850 wantErrMsg: "Some description (Conflict)",
1851 wantErr: false,
1852 },
1853 {
1854 name: "errors array of strings",
1855 args: args{
1856 input: `{"errors": ["fail1", "asplode2"]}`,
1857 statusCode: 500,
1858 },
1859 wantErrMsg: "fail1\nasplode2",
1860 wantErr: false,
1861 },
1862 {
1863 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