MCPcopy Index your code
hub / github.com/cli/cli / Test_parseErrorResponse

Function Test_parseErrorResponse

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

Source from the content-addressed store, hash-verified

1692}
1693
1694func Test_parseErrorResponse(t *testing.T) {
1695 type args struct {
1696 input string
1697 statusCode int
1698 }
1699 tests := []struct {
1700 name string
1701 args args
1702 wantErrMsg string
1703 wantErr bool
1704 }{
1705 {
1706 name: "no error",
1707 args: args{
1708 input: `{}`,
1709 statusCode: 500,
1710 },
1711 wantErrMsg: "",
1712 wantErr: false,
1713 },
1714 {
1715 name: "nil errors",
1716 args: args{
1717 input: `{"errors":null}`,
1718 statusCode: 500,
1719 },
1720 wantErrMsg: "",
1721 wantErr: false,
1722 },
1723 {
1724 name: "simple error",
1725 args: args{
1726 input: `{"message": "OH NOES"}`,
1727 statusCode: 500,
1728 },
1729 wantErrMsg: "OH NOES (HTTP 500)",
1730 wantErr: false,
1731 },
1732 {
1733 name: "errors string",
1734 args: args{
1735 input: `{"message": "Conflict", "errors": "Some description"}`,
1736 statusCode: 409,
1737 },
1738 wantErrMsg: "Some description (Conflict)",
1739 wantErr: false,
1740 },
1741 {
1742 name: "errors array of strings",
1743 args: args{
1744 input: `{"errors": ["fail1", "asplode2"]}`,
1745 statusCode: 500,
1746 },
1747 wantErrMsg: "fail1\nasplode2",
1748 wantErr: false,
1749 },
1750 {
1751 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