package main

import (
	"math/rand"
	"testing"
)

func dummyNewUser() *User {
	var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

	randSeq := func(n int) string {
		b := make([]rune, n)
		for i := range b {
			b[i] = letters[rand.Intn(len(letters))]
		}
		return string(b)
	}

	return &User{
		Username: randSeq(10),
		Password: randSeq(8),
	}
}

func TestUser(t *testing.T) {
	var u OAuth2User = &User{}
	_ = u
}

package main

import (
	"math/rand"
	"testing"
)

func dummyNewUser(password string) *User {
	var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

	randSeq := func(n int) string {
		b := make([]rune, n)
		for i := range b {
			b[i] = letters[rand.Intn(len(letters))]
		}
		return string(b)
	}

	u := &User{
		Username: randSeq(10),
	}
	u.Password = u.Hash(password)
	return u
}

func TestUser(t *testing.T) {
	var u OAuth2User = &User{}
	_ = u
}

Improve dummy user generate in example 2
Improve dummy user generate in example 2

Accept password as parameter to prevent hashing problem. Since hash
is used before saving the Password field, cannot get the real password
in the struct.
