| Conditions | 5 | 
| Total Lines | 51 | 
| Code Lines | 26 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | package campay  | 
            ||
| 15 | func TestNew(t *testing.T) { | 
            ||
| 16 | 	t.Run("default configuration is used when no option is set", func(t *testing.T) { | 
            ||
| 17 | // act  | 
            ||
| 18 | client := New()  | 
            ||
| 19 | |||
| 20 | // assert  | 
            ||
| 21 | assert.NotEmpty(t, client.environment)  | 
            ||
| 22 | assert.NotEmpty(t, client.common)  | 
            ||
| 23 | |||
| 24 | assert.Empty(t, client.apiUsername)  | 
            ||
| 25 | assert.Empty(t, client.apiPassword)  | 
            ||
| 26 | |||
| 27 | assert.NotNil(t, client.httpClient)  | 
            ||
| 28 | assert.NotNil(t, client.Transaction)  | 
            ||
| 29 | })  | 
            ||
| 30 | |||
| 31 | 	t.Run("single configuration value can be set using options", func(t *testing.T) { | 
            ||
| 32 | // Arrange  | 
            ||
| 33 | 		env := Environment("https://example.com") | 
            ||
| 34 | |||
| 35 | // Act  | 
            ||
| 36 | client := New(WithEnvironment(env))  | 
            ||
| 37 | |||
| 38 | // Assert  | 
            ||
| 39 | assert.NotNil(t, client.environment)  | 
            ||
| 40 | assert.Equal(t, env.String(), client.environment.String())  | 
            ||
| 41 | })  | 
            ||
| 42 | |||
| 43 | 	t.Run("multiple configuration values can be set using options", func(t *testing.T) { | 
            ||
| 44 | // Arrange  | 
            ||
| 45 | 		env := Environment("https://example.com") | 
            ||
| 46 | 		newHTTPClient := &http.Client{Timeout: 422} | 
            ||
| 47 | |||
| 48 | // Act  | 
            ||
| 49 | client := New(WithEnvironment(env), WithHTTPClient(newHTTPClient))  | 
            ||
| 50 | |||
| 51 | // Assert  | 
            ||
| 52 | assert.NotEmpty(t, client.environment)  | 
            ||
| 53 | assert.Equal(t, env.String(), client.environment.String())  | 
            ||
| 54 | |||
| 55 | assert.NotNil(t, client.httpClient)  | 
            ||
| 56 | assert.Equal(t, newHTTPClient.Timeout, client.httpClient.Timeout)  | 
            ||
| 57 | })  | 
            ||
| 58 | |||
| 59 | 	t.Run("it sets the Transaction service correctly", func(t *testing.T) { | 
            ||
| 60 | // Arrange  | 
            ||
| 61 | client := New()  | 
            ||
| 62 | |||
| 63 | // Assert  | 
            ||
| 64 | assert.NotNil(t, client.Transaction)  | 
            ||
| 65 | assert.Equal(t, client.environment.String(), client.Transaction.client.environment.String())  | 
            ||
| 66 | })  | 
            ||
| 168 |