| 28 | ) |
| 29 | |
| 30 | func Test_NewCmdApi(t *testing.T) { |
| 31 | f := &cmdutil.Factory{} |
| 32 | |
| 33 | tests := []struct { |
| 34 | name string |
| 35 | cli string |
| 36 | wants ApiOptions |
| 37 | wantsErr bool |
| 38 | }{ |
| 39 | { |
| 40 | name: "no flags", |
| 41 | cli: "graphql", |
| 42 | wants: ApiOptions{ |
| 43 | Hostname: "", |
| 44 | RequestMethod: "GET", |
| 45 | RequestMethodPassed: false, |
| 46 | RequestPath: "graphql", |
| 47 | RequestInputFile: "", |
| 48 | RawFields: []string(nil), |
| 49 | MagicFields: []string(nil), |
| 50 | RequestHeaders: []string(nil), |
| 51 | ShowResponseHeaders: false, |
| 52 | Paginate: false, |
| 53 | Silent: false, |
| 54 | CacheTTL: 0, |
| 55 | Template: "", |
| 56 | FilterOutput: "", |
| 57 | Verbose: false, |
| 58 | }, |
| 59 | wantsErr: false, |
| 60 | }, |
| 61 | { |
| 62 | name: "override method", |
| 63 | cli: "repos/octocat/Spoon-Knife -XDELETE", |
| 64 | wants: ApiOptions{ |
| 65 | Hostname: "", |
| 66 | RequestMethod: "DELETE", |
| 67 | RequestMethodPassed: true, |
| 68 | RequestPath: "repos/octocat/Spoon-Knife", |
| 69 | RequestInputFile: "", |
| 70 | RawFields: []string(nil), |
| 71 | MagicFields: []string(nil), |
| 72 | RequestHeaders: []string(nil), |
| 73 | ShowResponseHeaders: false, |
| 74 | Paginate: false, |
| 75 | Silent: false, |
| 76 | CacheTTL: 0, |
| 77 | Template: "", |
| 78 | FilterOutput: "", |
| 79 | Verbose: false, |
| 80 | }, |
| 81 | wantsErr: false, |
| 82 | }, |
| 83 | { |
| 84 | name: "with fields", |
| 85 | cli: "graphql -f query=QUERY -F body=@file.txt", |
| 86 | wants: ApiOptions{ |
| 87 | Hostname: "", |