You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			52 lines
		
	
	
		
			860 B
		
	
	
	
		
			Go
		
	
			
		
		
	
	
			52 lines
		
	
	
		
			860 B
		
	
	
	
		
			Go
		
	
| package integration
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"git.runcible.io/learning/ratchet/internal/assert"
 | |
| 	"git.runcible.io/learning/ratchet/internal/model"
 | |
| )
 | |
| 
 | |
| func TestUserModelExists(t *testing.T) {
 | |
| 	// Skip the test if the "-short" flag is provided when running the test.
 | |
| 	if testing.Short() {
 | |
| 		t.Skip("models: skipping model integration test")
 | |
| 	}
 | |
| 
 | |
| 	tests := []struct {
 | |
| 		name   string
 | |
| 		userID int
 | |
| 		want   bool
 | |
| 	}{{
 | |
| 		name:   "Valid ID",
 | |
| 		userID: 1337,
 | |
| 		want:   true,
 | |
| 	},
 | |
| 		{
 | |
| 			name:   "Zero ID",
 | |
| 			userID: 0,
 | |
| 			want:   false,
 | |
| 		},
 | |
| 		{
 | |
| 			name:   "Zero ID",
 | |
| 			userID: 2,
 | |
| 			want:   false,
 | |
| 		},
 | |
| 	}
 | |
| 
 | |
| 	for _, test := range tests {
 | |
| 		t.Run(test.name, func(t *testing.T) {
 | |
| 			db := newTestDB(t)
 | |
| 
 | |
| 			userService := model.UserService{db}
 | |
| 
 | |
| 			exists, err := userService.Exists(test.userID)
 | |
| 
 | |
| 			assert.Equal(t, exists, test.want)
 | |
| 			assert.NilError(t, err)
 | |
| 
 | |
| 		})
 | |
| 	}
 | |
| 
 | |
| }
 |