Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
f5654b0e
Commit
f5654b0e
authored
Jan 13, 2015
by
Bruno Pinto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converting bak plugin tests to fish-spec
parent
465e325a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
123 deletions
+114
-123
plugins/bak/bak.load
plugins/bak/bak.load
+3
-5
plugins/bak/spec/bak.spec.fish
plugins/bak/spec/bak.spec.fish
+111
-0
plugins/bak/tests/helper.fish
plugins/bak/tests/helper.fish
+0
-8
plugins/bak/tests/test_bak.fish
plugins/bak/tests/test_bak.fish
+0
-110
No files found.
plugins/bak/bak.load
View file @
f5654b0e
...
...
@@ -5,12 +5,10 @@ function __bak_help
end
function __bak_parse_help
function has_help_arg
# non implemented
end
if [ (count $argv) -lt 3 ]; or has_help_arg $argv
if [ (count $argv) -lt 3 ]
__bak_help $argv[1]
else
return 1
end
end
...
...
plugins/bak/spec/bak.spec.fish
0 → 100644
View file @
f5654b0e
import plugins/bak
import plugins/fish-spec
function describe_bak -d 'Testing bak plugin'
function before_all
set -g test_dir /tmp/bak_test
mkdir -p $test_dir
pushd
cd $test_dir
rm -rf $test_dir/*
end
function after_each
rm -rf $test_dir/*
end
function after_all
popd
end
function it_checks_bak_filename_pattern_is_followed
expect __is_bak '.ccnet.20140817_234302.bak' --to-be-true
expect __is_bak 'file\ with\ spaces.20140817_234302.bak' --to-be-true
expect __is_bak '.ccnet.bak' --to-be-false
end
function it_normalizes_file_name
expect (__bak_normalized '.ccnet.20140817_234302.bak') --to-equal '.ccnet'
expect (__bak_normalized 'file with spaces.20140817_234302.bak') --to-equal 'file with spaces'
end
function it_moves_a_single_file
touch a
mvbak a
expect __is_bak (ls) --to-be-true
end
function it_moves_multiple_files
touch a b
mvbak a b
for f in (ls)
expect __is_bak $f --to-be-true
end
end
function it_unmoves_a_single_file
touch a
mvbak a
unmvbak (ls)
expect (ls) --to-equal a
end
function it_unmoves_multiple_files
set files (seq 4)
touch $files
mvbak $files
unmvbak (ls)
expect (ls) --to-equal "$files"
end
function it_copies_a_single_file
touch a
cpbak a
expect (ls | sort) --to-equal (echo -e 'a' (__bak_name a) | sort)
end
function it_copies_multiple_files
set files (seq 4)
touch $files
cpbak $files
for f in $files
set files_bak $files_bak (__bak_name $f)
end
expect (ls | sort) --to-contain $files $file_bak
end
function it_uncopies_a_single_file
touch a
cpbak a
rm a
uncpbak (ls)
expect (ls | sort) --to-equal (echo -e 'a' (__bak_name a) | sort)
end
function it_uncopies_multiple_files
set files (seq 4)
touch $files
mvbak $files
unmvbak (ls)
expect (ls) --to-equal "$files"
end
function it_uncopies_a_directory
mkdir a
cpbak a/
rmdir a
uncpbak (ls -p)
expect (ls -p | sort) --to-equal (echo -e (__bak_name a)'/' 'a/')
end
end
spec.run $argv
plugins/bak/tests/helper.fish
deleted
100644 → 0
View file @
465e325a
set -l fish_tank /usr/local/share/fish-tank/tank.fish
if not test -e $fish_tank
echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)'
exit 1
end
source $fish_tank
source (dirname (status -f))/../*.fish
plugins/bak/tests/test_bak.fish
deleted
100755 → 0
View file @
465e325a
#!/usr/bin/env fish
function suite_bak
function setup
return 0
end
function teardown
rm -rf $test_dir/*
end
function test_is_bak
assert (__is_bak '.ccnet.20140817_234302.bak')
assert (__is_bak 'file with spaces.20140817_234302.bak')
assert (not __is_bak '.ccnet.bak')
end
function test_normalized
assert_equal '.ccnet' (__bak_normalized '.ccnet.20140817_234302.bak')
assert_equal 'file with spaces' (__bak_normalized 'file with spaces.20140817_234302.bak')
end
function test_mv_single
touch a
mvbak a
assert __is_bak (ls)
end
function test_mv_multiple
touch a b
mvbak a b
for f in (ls)
assert __is_bak $f
end
end
function test_unmv_single
touch a
mvbak a
unmvbak (ls)
assert_equal a (ls)
end
function test_unmv_multiple
set files (seq 4)
touch $files
mvbak $files
unmvbak (ls)
assert_equal "$files" (ls)
end
function test_cp_single
touch a
cpbak a
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
assert_equal "$expected" (ls | sort)
end
function test_uncp_single
touch a
cpbak a
rm a
uncpbak (ls)
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_uncp_dir_single
mkdir a
cpbak a/
rmdir a
uncpbak (ls -p)
assert_equal (echo -e 'a/' (__bak_name a)'/' | sort) (ls -p | sort)
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
rm $files
uncpbak (ls)
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
end
end
if not set -q tank_running
source (dirname (status -f))/helper.fish
set -g test_dir /tmp/bak_test
mkdir -p $test_dir
pushd
cd $test_dir
tank_run
popd
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment