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

Function Test_parseErrorResponse

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

Source from the content-addressed store, hash-verified

1772}
1773
1774func Test_parseErrorResponse(t *testing.T) {
1775 type args struct {
1776 input string
1777 statusCode int
1778 }
1779 tests := []struct {
1780 name string
1781 args args
1782 wantErrMsg string
1783 wantErr bool
1784 }{
1785 {
1786 name: "no error",
1787 args: args{
1788 input: `{}`,
1789 statusCode: 500,
1790 },
1791 wantErrMsg: "",
1792 wantErr: false,
1793 },
1794 {
1795 name: "nil errors",
1796 args: args{
1797 input: `{"errors":null}`,
1798 statusCode: 500,
1799 },
1800 wantErrMsg: "",
1801 wantErr: false,
1802 },
1803 {
1804 name: "simple error",
1805 args: args{
1806 input: `{"message": "OH NOES"}`,
1807 statusCode: 500,
1808 },
1809 wantErrMsg: "OH NOES (HTTP 500)",
1810 wantErr: false,
1811 },
1812 {
1813 name: "errors string",
1814 args: args{
1815 input: `{"message": "Conflict", "errors": "Some description"}`,
1816 statusCode: 409,
1817 },
1818 wantErrMsg: "Some description (Conflict)",
1819 wantErr: false,
1820 },
1821 {
1822 name: "errors array of strings",
1823 args: args{
1824 input: `{"errors": ["fail1", "asplode2"]}`,
1825 statusCode: 500,
1826 },
1827 wantErrMsg: "fail1\nasplode2",
1828 wantErr: false,
1829 },
1830 {
1831 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