diff options
author | EuAndreh <eu@euandre.org> | 2025-01-25 21:06:57 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-01-25 21:06:57 -0300 |
commit | 39346467ce203c2e3eebf0fbab687568f5e67119 (patch) | |
tree | 27366a9eaca73c59ee3fa80a9ab7f055b205cfdc | |
parent | tests/fiinha.go: Fix typo (diff) | |
download | fiinha-39346467ce203c2e3eebf0fbab687568f5e67119.tar.gz fiinha-39346467ce203c2e3eebf0fbab687568f5e67119.tar.xz |
tests/fiinha.go: Add test for `commands` var
-rw-r--r-- | src/fiinha.go | 14 | ||||
-rw-r--r-- | tests/fiinha.go | 11 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/fiinha.go b/src/fiinha.go index fe2fa6a..a20d7c7 100644 --- a/src/fiinha.go +++ b/src/fiinha.go @@ -2422,13 +2422,13 @@ func getopt( command := commandsMap[args.command] if command.name == "" { fmt.Fprintf(w, "Bad COMMAND: \"%s\".\n", args.command) - usage(allArgs[0], w) + usage(argv0, w) return argsT{}, commandT{}, 2 } args, ok := command.getopt(args, w) if !ok { - usage(allArgs[0], w) + usage(argv0, w) return argsT{}, commandT{}, 2 } @@ -2436,11 +2436,11 @@ func getopt( } func runCommand( - args argsT, + args argsT, command commandT, - stdin io.Reader, - stdout io.Writer, - stderr io.Writer, + stdin io.Reader, + stdout io.Writer, + stderr io.Writer, ) int { iqueue, err := NewWithPrefix(args.databasePath, args.prefix) if err != nil { @@ -2457,7 +2457,7 @@ func runCommand( return rc } -var commands = map[string]commandT { +var commands = map[string]commandT{ "in": commandT{ name: "in", getopt: topicGetopt, diff --git a/tests/fiinha.go b/tests/fiinha.go index b733935..b7a4cf5 100644 --- a/tests/fiinha.go +++ b/tests/fiinha.go @@ -5787,6 +5787,16 @@ func test_runCommand() { }) } +func test_commands() { + g.TestStart("commands") + + g.Testing("ensure map key and name are in sync", func() { + for key, command := range commands { + g.TAssertEqual(command.name, key) + } + }) +} + func dumpQueries() { queries := []struct{name string; fn func(string) queryT}{ @@ -5888,4 +5898,5 @@ func MainTest() { test_usage() test_getopt() test_runCommand() + test_commands() } |