package models_test

// import "github.com/gopherguides/learn/_training/fundamentals/testing/src/cover"
import (
	"fmt"
	"testing"

	models "github.com/gopherguides/learn/_training/fundamentals/testing/src/cover"
)

func TestUser_Validate(t *testing.T) {
	tests := []struct {
		user  models.User
		valid bool
	}{
		{user: models.User{}, valid: false},
		{user: models.User{First: "Rob"}, valid: false},
		{user: models.User{Last: "Pike"}, valid: false},
		{user: models.User{First: "Rob", Last: "Pike"}, valid: true},
	}
	for i, test := range tests {
		t.Run(fmt.Sprintf("%d", i), func(st *testing.T) {
			err := test.user.Validate()
			if err != nil && test.valid {
				st.Errorf("unexpected error: %s", err)
			}
		})
	}
}
