(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestCreateAccount(t *testing.T) { |
| 17 | router, _, err := setupRouter(t) |
| 18 | if err != nil { |
| 19 | t.Fatalf("Failed to setup router: %v", err) |
| 20 | } |
| 21 | |
| 22 | tests := []struct { |
| 23 | name string |
| 24 | payload model2.CreateAccount |
| 25 | expectedCode int |
| 26 | wantErr bool |
| 27 | }{ |
| 28 | { |
| 29 | name: "Missing required fields", |
| 30 | payload: model2.CreateAccount{ |
| 31 | BankName: "Test Bank", |
| 32 | Number: gofakeit.AchAccount(), |
| 33 | }, |
| 34 | expectedCode: http.StatusBadRequest, |
| 35 | wantErr: false, |
| 36 | }, |
| 37 | { |
| 38 | name: "Both BalanceId and LedgerId provided", |
| 39 | payload: model2.CreateAccount{ |
| 40 | BankName: "Test Bank", |
| 41 | Number: gofakeit.AchAccount(), |
| 42 | BalanceId: "bln_123", |
| 43 | LedgerId: "ldg_123", |
| 44 | }, |
| 45 | expectedCode: http.StatusBadRequest, |
| 46 | wantErr: false, |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | for _, tt := range tests { |
| 51 | t.Run(tt.name, func(t *testing.T) { |
| 52 | payloadBytes, _ := request.ToJsonReq(&tt.payload) |
| 53 | var response map[string]interface{} |
| 54 | testRequest := TestRequest{ |
| 55 | Payload: payloadBytes, |
| 56 | Response: &response, |
| 57 | Method: "POST", |
| 58 | Route: "/accounts", |
| 59 | Auth: "", |
| 60 | Router: router, |
| 61 | } |
| 62 | |
| 63 | resp, _ := SetUpTestRequest(testRequest) |
| 64 | assert.Equal(t, tt.expectedCode, resp.Code) |
| 65 | }) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | func TestGetAccount(t *testing.T) { |
| 70 | router, b, err := setupRouter(t) |
nothing calls this directly
no test coverage detected