mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
refactor: cleanup code
This commit is contained in:
@@ -290,73 +290,5 @@ func (m *model_ca) TempAddAuthor() {
|
|||||||
i := item(item_str)
|
i := item(item_str)
|
||||||
parent_m.list.InsertItem(len(parent_m.list.Items())+1, item(item_str))
|
parent_m.list.InsertItem(len(parent_m.list.Items())+1, item(item_str))
|
||||||
selectToggle(i)
|
selectToggle(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func Entry_CA() string {
|
|
||||||
// m, err := tea.NewProgram(initialModel("author")).Run()
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Printf("could not start program: %s\n", err)
|
|
||||||
// os.Exit(1)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if len(m.(model_ca).inputs) > 0 &&
|
|
||||||
// m.(model_ca).inputs[0].Value() != "" &&
|
|
||||||
// m.(model_ca).inputs[1].Value() != "" &&
|
|
||||||
// m.(model_ca).inputs[2].Value() != "" &&
|
|
||||||
// m.(model_ca).inputs[3].Value() != "" {
|
|
||||||
// author_file := utils.Find_authorfile()
|
|
||||||
// f, err := os.OpenFile(author_file, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
|
||||||
// if err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// defer f.Close()
|
|
||||||
|
|
||||||
// sb := strings.Builder{}
|
|
||||||
// sb.WriteRune('\n')
|
|
||||||
|
|
||||||
// sb.WriteString(fmt.Sprintf("%s|%s|%s|%s",
|
|
||||||
// m.(model_ca).inputs[0].Value(),
|
|
||||||
// m.(model_ca).inputs[1].Value(),
|
|
||||||
// m.(model_ca).inputs[2].Value(),
|
|
||||||
// m.(model_ca).inputs[3].Value()))
|
|
||||||
|
|
||||||
// if m.(model_ca).exclude {
|
|
||||||
// sb.WriteString(fmt.Sprintf("|%s", "ex"))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if m.(model_ca).inputs[4].Value() != "" {
|
|
||||||
// sb.WriteString(fmt.Sprintf(";;%s", m.(model_ca).inputs[4].Value()))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //sb.WriteRune('\n')
|
|
||||||
|
|
||||||
// if _, err = f.WriteString(sb.String()); err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
// utils.Define_users(utils.Find_authorfile())
|
|
||||||
// return m.(model_ca).inputs[0].Value()
|
|
||||||
// }
|
|
||||||
// return ""
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Entry_TA() string {
|
|
||||||
// //old_m = old_m
|
|
||||||
|
|
||||||
// m, err := tea.NewProgram(initialModel("temp")).Run()
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Printf("could not start program: %s\n", err)
|
|
||||||
// os.Exit(1)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if len(m.(model_ca).inputs) > 0 &&
|
|
||||||
// m.(model_ca).inputs[0].Value() != "" &&
|
|
||||||
// m.(model_ca).inputs[1].Value() != "" {
|
|
||||||
// utils.TempAddUser(m.(model_ca).inputs[0].Value(), m.(model_ca).inputs[1].Value())
|
|
||||||
// return m.(model_ca).inputs[0].Value() + ":" + m.(model_ca).inputs[1].Value()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return ""
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case key.Matches(msg, m.keys.groupSelect):
|
case key.Matches(msg, m.keys.groupSelect):
|
||||||
// TODO: Look into how to select multiple groups
|
// TODO: Look into how to select multiple groups
|
||||||
sub_model = newModel()
|
sub_model = newModel()
|
||||||
//group := Entry_GR()
|
|
||||||
return m, tea.ClearScreen
|
return m, tea.ClearScreen
|
||||||
|
|
||||||
case key.Matches(msg, m.keys.tempAdd):
|
case key.Matches(msg, m.keys.tempAdd):
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func setup() {
|
|||||||
}
|
}
|
||||||
os.Setenv("author_file", "author_file_test")
|
os.Setenv("author_file", "author_file_test")
|
||||||
envVar = os.Getenv("author_file")
|
envVar = os.Getenv("author_file")
|
||||||
|
|
||||||
utils.Define_users("author_file_test")
|
utils.Define_users("author_file_test")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ func teardown() {
|
|||||||
// remove test data
|
// remove test data
|
||||||
os.Remove("author_file_test")
|
os.Remove("author_file_test")
|
||||||
os.Setenv("author_file", envVar)
|
os.Setenv("author_file", envVar)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tui_show_users TESTS BEGIN
|
// tui_show_users TESTS BEGIN
|
||||||
@@ -164,7 +163,7 @@ func Test_EntryCA(t *testing.T) {
|
|||||||
Runes: []rune("enter"),
|
Runes: []rune("enter"),
|
||||||
})
|
})
|
||||||
|
|
||||||
tm.Type("gr1")
|
tm.Type("gr6")
|
||||||
tm.Send(tea.KeyMsg{
|
tm.Send(tea.KeyMsg{
|
||||||
Type: tea.KeyRunes,
|
Type: tea.KeyRunes,
|
||||||
Runes: []rune("enter"),
|
Runes: []rune("enter"),
|
||||||
@@ -196,12 +195,11 @@ func Test_EntryCA(t *testing.T) {
|
|||||||
t.Errorf("Expected 3 inputs, got %d\n%v", len(m.list.Items()), m.list.Items())
|
t.Errorf("Expected 3 inputs, got %d\n%v", len(m.list.Items()), m.list.Items())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: For some reason the test is not writing to the author file despite working in the actual program
|
//TODO: For some reason the test is not writing to the author file despite working in the actual program
|
||||||
// var user utils.User
|
// var user utils.User
|
||||||
// utils.Define_users("author_file_test")
|
// utils.Define_users("author_file_test")
|
||||||
// data, _ := os.ReadFile("author_file_test")
|
// data, _ := os.ReadFile("author_file_test")
|
||||||
// t.Errorf("Data: %s", data)
|
// t.Errorf("Data: %s", data)
|
||||||
|
|
||||||
// if _, ok := utils.Users["test"]; !ok {
|
// if _, ok := utils.Users["test"]; !ok {
|
||||||
// t.Errorf("Expected 'testing2' to be in the users map")
|
// t.Errorf("Expected 'testing2' to be in the users map")
|
||||||
@@ -405,6 +403,8 @@ func Test_GroupSelection(t *testing.T) {
|
|||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
|
t.Errorf("%v", elected)
|
||||||
|
|
||||||
m := listModel()
|
m := listModel()
|
||||||
tm := teatest.NewTestModel(
|
tm := teatest.NewTestModel(
|
||||||
t, m, teatest.WithInitialTermSize(300, 300),
|
t, m, teatest.WithInitialTermSize(300, 300),
|
||||||
@@ -430,6 +430,9 @@ func Test_GroupSelection(t *testing.T) {
|
|||||||
t.Errorf("Expected model, got %T", fm)
|
t.Errorf("Expected model, got %T", fm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.Errorf("%v", utils.Groups)
|
||||||
|
t.Errorf("%v", selected)
|
||||||
|
|
||||||
if len(selected) != 1 {
|
if len(selected) != 1 {
|
||||||
t.Errorf("Expected 1 selected item, got %d", len(selected))
|
t.Errorf("Expected 1 selected item, got %d", len(selected))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user