(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestUpdateReplace(t *testing.T) { |
| 27 | wb := SetupWorkbench(t) |
| 28 | defer wb.Close() |
| 29 | |
| 30 | shellPid := strconv.Itoa(wb.LaunchFakeShell()) |
| 31 | |
| 32 | wb.RunCodCmd("init", shellPid, "bash") |
| 33 | |
| 34 | tmpCat := wb.InTmpDataPath("foo") |
| 35 | wb.CopyFile("binaries/foo_v1.py", tmpCat) |
| 36 | wb.RunCodCmd("learn", "--", tmpCat, "--help") |
| 37 | out := wb.RunCodCmd("api", "complete-words", shellPid, "--", "1", tmpCat, "--") |
| 38 | completions := wb.SplitLines(out) |
| 39 | sort.Strings(completions) |
| 40 | require.Equal(t, []string{"--bar1", "--foo1"}, completions) |
| 41 | |
| 42 | wb.CopyFile("binaries/foo_v2.py", tmpCat) |
| 43 | wb.RunCodCmd("update", "**") |
| 44 | |
| 45 | out = wb.RunCodCmd("list") |
| 46 | parsed := wb.ParseCodListCommands(out) |
| 47 | require.Equal(t, |
| 48 | []string{ |
| 49 | "foo --help", |
| 50 | }, |
| 51 | parsed) |
| 52 | |
| 53 | out = wb.RunCodCmd("api", "complete-words", shellPid, "--", "1", tmpCat, "--") |
| 54 | completions = wb.SplitLines(out) |
| 55 | sort.Strings(completions) |
| 56 | require.Equal(t, []string{"--bar2", "--foo2", "--qux2"}, completions) |
| 57 | } |
| 58 | |
| 59 | func TestUpdateMerge(t *testing.T) { |
| 60 | wb := SetupWorkbench(t) |
nothing calls this directly
no test coverage detected