func TestSQLFiles(t *testing.T) {
	t.Run("BadFS", func(t *testing.T) {
		e := EmbeddedData{
			SQLFS: fstest.MapFS{},
		}
		_, err := e.sqlFiles()
		if err == nil {
			t.Error("wanted error with file system without desired sql files")
		}
	})
	t.Run("OkFS", func(t *testing.T) {
		e := EmbeddedData{
			SQLFS: fstest.MapFS{
				"user_create.sql":                  &fstest.MapFile{Data: []byte("2")},
				"user_delete.sql":                  &fstest.MapFile{Data: []byte("6")},
				"user_read.sql":                    &fstest.MapFile{Data: []byte("3")},
				"users.sql":                        &fstest.MapFile{Data: []byte("1")},
				"user_update_password.sql":         &fstest.MapFile{Data: []byte("4")},
				"user_update_points_increment.sql": &fstest.MapFile{Data: []byte("5")},
			},
		}
		gotFiles, err := e.sqlFiles()
		wantFileData := []string{"1", "2", "3", "4", "5", "6"}
		switch {
		case err != nil:
			t.Errorf("unwanted error: %v", err)
		case len(wantFileData) != len(gotFiles):
			t.Errorf("wanted %v files, got %v", len(wantFileData), len(gotFiles))
		default:
			for j, f := range gotFiles {
				b, err := io.ReadAll(f)
				switch {
				case err != nil:
					t.Errorf("could not read file %v: %v", j, err)
				case wantFileData[j] != string(b):
					t.Errorf("wanted file %v to be %v, got %s", j, wantFileData[j], b)
				}
			}
		}
	})
}
// TestSQLFiles ensures the files are en order before being sent to the database.
// The table creation scripts must be run before other scripts reference the tables.
TestSQLFiles ensures the files are en order before being sent to the database.
The table creation scripts must be run before other scripts reference the tables.
// TestSQLFiles ensures the files are en order before being sent to the database . // The table creation scripts must be run before other scripts reference the tables .
func TestSQLFiles(t *testing.T) {
	t.Run("BadFS", func(t *testing.T) {
		e := EmbeddedData{
			SQLFS: fstest.MapFS{},
		}
		_, err := e.sqlFiles()
		if err == nil {
			t.Error("wanted error with file system without desired sql files")
		}
	})
	t.Run("OkFS", func(t *testing.T) {
		e := EmbeddedData{
			SQLFS: fstest.MapFS{
				"user_create.sql":                  &fstest.MapFile{Data: []byte("2")},
				"user_delete.sql":                  &fstest.MapFile{Data: []byte("6")},
				"user_read.sql":                    &fstest.MapFile{Data: []byte("3")},
				"users.sql":                        &fstest.MapFile{Data: []byte("1")},
				"user_update_password.sql":         &fstest.MapFile{Data: []byte("4")},
				"user_update_points_increment.sql": &fstest.MapFile{Data: []byte("5")},
			},
		}
		gotFiles, err := e.sqlFiles()
		wantFileData := []string{"1", "2", "3", "4", "5", "6"}
		switch {
		case err != nil:
			t.Errorf("unwanted error: %v", err)
		case len(wantFileData) != len(gotFiles):
			t.Errorf("wanted %v files, got %v", len(wantFileData), len(gotFiles))
		default:
			for j, f := range gotFiles {
				b, err := io.ReadAll(f)
				switch {
				case err != nil:
					t.Errorf("could not read file %v: %v", j, err)
				case wantFileData[j] != string(b):
					t.Errorf("wanted file %v to be %v, got %s", j, wantFileData[j], b)
				}
			}
		}
	})
}
func TestSQLFiles ( t * testing . T ) { t . Run ( " " , func ( t * testing . T ) { e := EmbeddedData { SQLFS : fstest . MapFS { } , } _ , err := e . sqlFiles ( ) if err == nil { t . Error ( " " ) } } ) t . Run ( " " , func ( t * testing . T ) { e := EmbeddedData { SQLFS : fstest . MapFS { " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , " " : & fstest . MapFile { Data : [ ] byte ( " " ) } , } , } gotFiles , err := e . sqlFiles ( ) wantFileData := [ ] string { " " , " " , " " , " " , " " , " " } switch { case err != nil : t . Errorf ( " " , err ) case len ( wantFileData ) != len ( gotFiles ) : t . Errorf ( " " , len ( wantFileData ) , len ( gotFiles ) ) default : for j , f := range gotFiles { b , err := io . ReadAll ( f ) switch { case err != nil : t . Errorf ( " " , j , err ) case wantFileData [ j ] != string ( b ) : t . Errorf ( " " , j , wantFileData [ j ] , b ) } } } } ) }
TestSQLFiles ensures the files are en order before being sent to the database.
TestSQLFiles ensures the files are en order before being sent to the database .