fisher/test/search.fish
Jorge Bucaran 916ea28c1e
Power up search Close #115,#128
* Search now has a color display mode enabled by default when listing
  records for human consumption, but continues to produce easy to parse
  output when selecting specific fields.

* The following example queries:

  * fisher search --name
  * fisher search --url
  * fisher search --name --url
  * fisher search --tag=prompt --name

  and so forth continue to display easy to parse output.

* The following example queries:

  * fisher search
  * fisher search --name=fishtape
  * fisher search --tag=prompt
  * fisher search --author=joe

  display in color by default and support multiple formats using the
  --format option described below. The colors used are selected from
  $fish_color_* variables for best results.

* To disable color output, use --no-color. To customize the display
  format use any of the following keywords:

  * --format=*oneline* (default)
  * --format=*short*
  * --format=*verbose*
  * --format=*longline*
  * --format=*raw*

* Search now shows unique records when listing --authors only. #128
2016-02-26 16:59:47 +09:00

107 lines
2.8 KiB
Fish

set -l path $DIRNAME/.t-$TESTNAME-(random)
function -S setup
mkdir -p $path
set -g fisher_cache $path
set -g fisher_index file://$DIRNAME/fixtures/plugins/index
__fisher_index_update
function spin -a commands
eval "$commands"
end
end
function -S teardown
rm -rf $path
functions -e spin
end
test "$TESTNAME - Get only names from index"
foo bar baz foobar = (fisher search --name)
end
test "$TESTNAME - Get only URLs from index"
"https://github.com/foo" \
"https://github.com/bar" \
"https://github.com/baz" \
"https://github.com/foobar" = (fisher search --url)
end
test "$TESTNAME - Get only info from index"
"about foo" "about bar" "about baz" "about foobar" = (fisher search --info)
end
test "$TESTNAME - Get only tags from index"
foo bar baz = (fisher search --tag)
end
test "$TESTNAME - Get only authors from index"
foosmith barsmith bazsmith foobarson = (fisher search --author)
end
test "$TESTNAME - Get full record"
"foo" "https://github.com/foo" "about foo" "foo" "foosmith" = (fisher search --format=raw --name=foo --no-color)
end
test "$TESTNAME - Match name and get name"
"foo" = (fisher search --name=foo --name)
end
test "$TESTNAME - Match name and get URL"
"https://github.com/foo" = (fisher search --name=foo --url)
end
test "$TESTNAME - Match name and get info"
"about foo" = (fisher search --name=foo --info)
end
test "$TESTNAME - Match name and get tag/s"
"foo" "bar" = (fisher search --name=foobar --tag)
end
test "$TESTNAME - Match name and get author"
"foosmith" = (fisher search --name=foo --author)
end
test "$TESTNAME - Match tag and get author #1"
"foosmith" "foobarson" = (fisher search --tag=foo --author)
end
test "$TESTNAME - Match tag and get author #2"
"barsmith" "foobarson" = (fisher search --tag=bar --author)
end
test "$TESTNAME - Match name regex and get author"
"barsmith" "bazsmith" = (fisher search --name~/^b/ --author)
end
test "$TESTNAME - Match author regex and get url"
"https://github.com/foo" \
"https://github.com/bar" \
"https://github.com/baz" \
"https://github.com/foobar" = (fisher search --author~/^[fb]/ --url)
end
test "$TESTNAME - Match multiple tags with OR join (default) and get name"
foobar foo bar = (fisher search --tag={foo,bar} --name)
end
test "$TESTNAME - Match multiple tags with AND join and get name"
foobar = (fisher search --and --tag={foo,bar} --name)
end
test "$TESTNAME - Match field and get multiple fields #1"
"bar;https://github.com/bar" "baz;https://github.com/baz" = (
fisher search --name~/^b/ --name --url)
end
test "$TESTNAME - Match field and get multiple fields #2"
"foosmith;foo" "foobarson;bar" = (fisher search --name~/^f/ --author --tags)
end
test "$TESTNAME - Get full index"
(fisher search --format=raw) = (cat $fisher_cache/.index)
end