refactor: change model structure of show users for testing

This commit is contained in:
Slug-Boi
2024-10-24 20:47:53 +02:00
parent b0a5125113
commit fbfde5999f
+16 -5
View File
@@ -82,7 +82,18 @@ func (e example) helpView() string {
return helpStyle_us("\n ↑/↓: Navigate • q: Quit\n")
}
func Entry_US(author_file string) {
func intialModel_US(author_file string) tea.Model {
loadData(author_file)
model, err := newExample()
if err != nil {
fmt.Println("Could not initialize Bubble Tea model:", err)
os.Exit(1)
}
return model
}
func loadData(author_file string) {
file, err := os.Open(author_file)
if err != nil {
fmt.Println("Could not open file:", err)
@@ -103,12 +114,12 @@ func Entry_US(author_file string) {
content = cnt.String()
model, err := newExample()
if err != nil {
fmt.Println("Could not initialize Bubble Tea model:", err)
os.Exit(1)
}
func Entry_US(author_file string) {
model := intialModel_US(author_file)
if _, err := tea.NewProgram(model).Run(); err != nil {
fmt.Println("Bummer, there's been an error:", err)
os.Exit(1)