<commit_before>package models

import (
	"reflect"
	"testing"

	"github.com/alice02/go-todoapi/database"
)

func TestNewTaskModel(t *testing.T) {
	u := NewTaskModel(nil)
	expected := "*models.taskModel"
	actual := reflect.TypeOf(u).String()
	if actual != expected {
		t.Errorf("got %v want %v", actual, expected)
	}
}

func TestSaveAndFind(t *testing.T) {
	expected := []Task{
		{
			Description: "test1",
			Completed:   false,
		},
		{
			Description: "test2",
			Completed:   true,
		},
		{
			Description: "",
			Completed:   false,
		},
	}

	db, err := database.NewDB()
	if err != nil {
		panic(err)
	}
	db.AutoMigrate(&Task{})
	u := NewTaskModel(db)

	for _, task := range expected {
		err = u.Save(&task)
		if err != nil {
			t.Errorf("database save failed")
		}
	}
	actual, err := u.FindAll()

	if len(actual) != len(expected) {
		t.Errorf("got length %v want %v", len(actual), (expected))
	}
	for i := range actual {
		if actual[i].Description != expected[i].Description {
			t.Errorf("got %v want %v", actual[i].Description, expected[i].Description)
		}
		if actual[i].Completed != expected[i].Completed {
			t.Errorf("got %v want %v", actual[i].Description, expected[i].Description)
		}
	}

	db.DropTableIfExists(&Task{})
}

func TestUpdate(t *testing.T) {
}
<commit_msg>Fix test failed message of task model on TestSaveAndFind()<commit_after>package models

import (
	"reflect"
	"testing"

	"github.com/alice02/go-todoapi/database"
)

func TestNewTaskModel(t *testing.T) {
	u := NewTaskModel(nil)
	expected := "*models.taskModel"
	actual := reflect.TypeOf(u).String()
	if actual != expected {
		t.Errorf("got %v want %v", actual, expected)
	}
}

func TestSaveAndFind(t *testing.T) {
	expected := []Task{
		{
			Description: "test1",
			Completed:   false,
		},
		{
			Description: "test2",
			Completed:   true,
		},
		{
			Description: "",
			Completed:   false,
		},
	}

	db, err := database.NewDB()
	if err != nil {
		panic(err)
	}
	db.AutoMigrate(&Task{})
	u := NewTaskModel(db)

	for _, task := range expected {
		err = u.Save(&task)
		if err != nil {
			t.Errorf("database save failed")
		}
	}
	actual, err := u.FindAll()

	if len(actual) != len(expected) {
		t.Errorf("got length %v want %v", len(actual), (expected))
	}
	for i := range actual {
		if actual[i].Description != expected[i].Description {
			t.Errorf("got %v want %v", actual[i].Description, expected[i].Description)
		}
		if actual[i].Completed != expected[i].Completed {
			t.Errorf("got %v want %v", actual[i].Completed, expected[i].Completed)
		}
	}

	db.DropTableIfExists(&Task{})
}

func TestUpdate(t *testing.T) {
}

{'fraction_non_alphanumeric': 0.17428023032629558, 'fraction_numerical': 0.003071017274472169, 'mean_word_length': 3.645276292335116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2181936', 'n_tokens_mistral': 1035, 'n_tokens_neox': 954, 'n_words': 210}