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