func TestCreateUser(t *testing.T) {

	util.WithCleanDB(func() {
		var (
			user *models.User = &models.User{
				FirstName: "Robbie",
				LastName:  "McKinstry",
				Username:  "******",
				Password:  []byte("0000"),
			}
		)

		err := UserStore.Create(user)
		if err != nil {
			t.Fatal(err)
		}

		if user.ID == 0 {
			t.Fatal("Failed to set a new ID for a created user")
		}

		observedUser, err := UserStore.GetByID(user.ID)
		if err != nil {
			t.Fatal(err)
		}

		if !user.Equals(observedUser) {
			t.Fatal("Observed user did not match the original user.")
		}
	})

}
func TestCreateTeacher(t *testing.T) {
	util.WithCleanDB(func() {
		var (
			teacher *Teacher = &Teacher{
				User: User{
					FirstName: "Mark",
					LastName:  "Krotec",
					Username:  "******",
					Password:  []byte("0000"),
				},
			}
		)

		err := TeacherStore.Create(teacher)
		if err != nil {
			t.Fatal(err)
		}

		if teacher.ID == 0 {
			t.Fatal("Failed to set a new ID for a created teacher")
		}
		if teacher.User.ID == 0 {
			t.Fatal("Failed to set a new ID for a created user")
		}

		observedTeacher, err := TeacherStore.GetByID(teacher.ID)
		if err != nil {
			t.Fatal(err)
		}

		if !teacher.Equals(observedTeacher) {
			t.Fatal("Observed student did not match the original user.")
		}
	})
}
func TestCreateStudent(t *testing.T) {
	util.WithCleanDB(func() {
		var (
			student *Student = &Student{
				User: User{
					FirstName: "Robbie",
					LastName:  "McKinstry",
					Username:  "******",
					Password:  []byte("0000"),
				},
			}
		)

		err := StudentStore.Create(student)
		if err != nil {
			t.Fatal(err)
		}

		if student.ID == 0 {
			t.Fatal("Failed to set a new ID for a created student")
		}
		if student.User.ID == 0 {
			t.Fatal("Failed to set a new ID for a created user")
		}

		observedStudent, err := StudentStore.GetByID(student.ID)
		if err != nil {
			t.Fatal(err)
		}

		if !student.Equals(observedStudent) {
			fmt.Println("Observed: %v\n", observedStudent)
			fmt.Println("Expected: %v\n", student)
			t.Fatal("Observed student did not match the original user.")

		}
	})
}
func TestCreateCourse(t *testing.T) {
	util.WithCleanDB(func() {

		var (
			teachers = []*Teacher{
				{
					User: User{
						FirstName: "Jon",
						LastName:  "Misurda",
						Username:  "******",
						Password:  []byte("0000"),
					},
				}, {
					User: User{
						FirstName: "Sebastion",
						LastName:  "Awful",
						Username:  "******",
						Password:  []byte("0000"),
					},
				},
			}

			students = []*Student{
				{
					User: User{
						FirstName: "Neel",
						LastName:  "Kowdley",
						Username:  "******",
						Password:  []byte("0000"),
					},
				}, {
					User: User{
						FirstName: "Dave",
						LastName:  "Sweeney",
						Username:  "******",
						Password:  []byte("0000"),
					},
				},
			}
		)

		for _, teacher := range teachers {
			if err := TeacherStore.Create(teacher); err != nil {
				t.Fatal(err)
			}
			if teacher.ID == 0 {
				t.Fatal("No ID on teacher.")
			}
			if teacher.User.ID == 0 {
				t.Fatal("No ID on teacher.User")
			}
		}

		for _, student := range students {
			if err := StudentStore.Create(student); err != nil {
				t.Fatal(err)
			}
			if student.ID == 0 {
				t.Fatal("No ID on student")
			}
			if student.User.ID == 0 {
				t.Fatal("No ID on student.User")
			}
		}

		var course *Course = &Course{
			Name:     "Dr. Misurda's Wild Ride",
			Teachers: teachers,
			Students: students,
		}

		if err := CourseStore.Create(course); err != nil {
			t.Fatal(err)
		}

		if course.ID == 0 {
			t.Fatal("Failed to set a new ID for a created assignment")
		}

		observedCourse, err := CourseStore.GetByID(course.ID)
		if err != nil {
			t.Fatal(err)
		}

		if !course.Equals(observedCourse) {
			fmt.Printf("Observed Course: %v \n", observedCourse)
			fmt.Printf("Expected Course: %v \n", course)
			t.Fatal("Observed course did not match the original course.")
		}
	})
}