| 21 | return &ctx |
| 22 | } |
| 23 | func TestNewServer_DefaultConfig(t *testing.T) { |
| 24 | server := New() |
| 25 | |
| 26 | // Assert default config values |
| 27 | if server.config.BodyLimit != 5*1024*1024 { // 5 MB |
| 28 | t.Errorf("expected BodyLimit to be %d, got %d", 5*1024*1024, server.config.BodyLimit) |
| 29 | } |
| 30 | if server.config.ReadTimeout != 5*time.Second { |
| 31 | t.Errorf("expected ReadTimeout to be 5s, got %s", server.config.ReadTimeout) |
| 32 | } |
| 33 | if server.config.WriteTimeout != 5*time.Second { |
| 34 | t.Errorf("expected WriteTimeout to be 5s, got %s", server.config.WriteTimeout) |
| 35 | } |
| 36 | if server.config.DisableKeepAlive != false { |
| 37 | t.Errorf("expected DisableKeepAlive to be false, got %v", server.config.DisableKeepAlive) |
| 38 | } |
| 39 | if server.config.UploadPath != "./uploads/" { |
| 40 | t.Errorf("expected UploadPath to be './uploads/', got '%s'", server.config.UploadPath) |
| 41 | } |
| 42 | if server.config.JSONEncoder == nil { |
| 43 | t.Error("expected JSONEncoder to be set") |
| 44 | } |
| 45 | if server.config.JSONDecoder == nil { |
| 46 | t.Error("expected JSONDecoder to be set") |
| 47 | } |
| 48 | if len(server.config.RequestMethods) == 0 { |
| 49 | t.Error("expected RequestMethods to not be empty") |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestNewServer_CustomConfig(t *testing.T) { |
| 54 | customConfig := Config{ |