func TestStore_DeleteUser(t *testing.T) {
	s := OpenStore()
	defer s.Close()
	if err := s.CreateUser(&main.User{Username: "susy"}); err != nil {
		t.Fatal(err)
	}
	if err := s.DeleteUser(1); err != nil {
		t.Fatal(err)
	}
	if u, err := s.User(1); err != nil {
		t.Fatal(err)
	} else if u != nil {
		t.Fatalf("unexpected user: %#v", u)
	}
}
Ensure store can remove a user.
package main_test
import (
	"io/ioutil"
	"os"
	"reflect"
	"testing"
	main "github.com/benbjohnson/application-development-using-boltdb"
)
func TestStore_CreateUser(t *testing.T) {
	s := OpenStore()
	defer s.Close()
	u := &main.User{Username: "susy"}
	if err := s.CreateUser(u); err != nil {
		t.Fatal(err)
	} else if u.ID != 1 {
		t.Fatalf("unexpected ID: %d", u.ID)
	}
	other, err := s.User(1)
	if err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(other, u) {
		t.Fatalf("unexpected user: %#v", other)
	}
}
func TestStore_Users(t *testing.T) {
	s := OpenStore()
	defer s.Close()
	if err := s.CreateUser(&main.User{Username: "susy"}); err != nil {
		t.Fatal(err)
	} else if err := s.CreateUser(&main.User{Username: "john"}); err != nil {
		t.Fatal(err)
	}
	if a, err := s.Users(); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(a, []*main.User{
		{ID: 1, Username: "susy"},
		{ID: 2, Username: "john"},
	}) {
		t.Fatalf("unexpected users: %#v", a)
	}
}
func TestStore_SetUsername(t *testing.T) {
	s := OpenStore()
	defer s.Close()
	if err := s.CreateUser(&main.User{Username: "susy"}); err != nil {
		t.Fatal(err)
	}
	if err := s.SetUsername(1, "jimbo"); err != nil {
		t.Fatal(err)
	}
	if u, err := s.User(1); err != nil {
		t.Fatal(err)
	} else if u.Username != "jimbo" {
		t.Fatalf("unexpected username: %s", u.Username)
	}
}
func TestStore_SetUsername_ErrUserNotFound(t *testing.T) {
	s := OpenStore()
	defer s.Close()
	if err := s.SetUsername(1, "jimbo"); err != main.ErrUserNotFound {
		t.Fatalf("unexpected error: %v", err)
	}
}