Skip to content

Commit

Permalink
Add test of unite sources giti remote
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnk committed Oct 23, 2012
1 parent b6f6f3e commit e14460e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions autoload/unite/sources/giti/remote.vim
Expand Up @@ -41,6 +41,18 @@ endfunction"}}}
" local functions {{{
" }}}

" context getter {{{
function! s:get_SID()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
let s:SID = s:get_SID()
delfunction s:get_SID

function! unite#sources#giti#remote#__context__()
return { 'sid': s:SID, 'scope': s: }
endfunction
"}}}

let &cpo = s:save_cpo
unlet s:save_cpo
" __END__
1 change: 1 addition & 0 deletions test/autoload/unite/sources/giti/test_all.vim
Expand Up @@ -4,3 +4,4 @@ execute 'source' s:here . '/test_branch.vim'
execute 'source' s:here . '/test_branch_all.vim'
execute 'source' s:here . '/test_config.vim'
execute 'source' s:here . '/test_log.vim'
execute 'source' s:here . '/test_remote.vim'
47 changes: 47 additions & 0 deletions test/autoload/unite/sources/giti/test_remote.vim
@@ -0,0 +1,47 @@
let s:tc = unittest#testcase#new('autoload/unite/sources/giti/remote.vim',
\ unite#sources#giti#remote#__context__())

let s:list = ['hoge']

function! s:tc.SETUP()"{{{
function! giti#remote#show()"{{{
return s:list
endfunction"}}}
endfunction"}}}
function! s:tc.TEARDOWN()"{{{
let paths = split(globpath(&rtp, 'autoload/unite/sources/giti/remote.vim'), '\n')
execute 'source ' . paths[0]
endfunction"}}}

function! s:tc.test_define()"{{{
call self.assert_equal(
\ type({}),
\ type(unite#sources#giti#remote#define()),
\ )
call self.assert_throw('E118', 'call self.call("unite#sources#giti#remote#define", [""])')
endfunction"}}}

function! s:tc.test_source_gather_candidate()"{{{
let source = self.get('s:source')
let candidates = source.gather_candidates('', '')
call self.assert_equal(type([]), type(candidates))
call self.assert(has_key(candidates[0], 'word'))
call self.assert(has_key(candidates[0], 'source'))
call self.assert(has_key(candidates[0], 'kind'))
call self.assert(has_key(candidates[0], 'action__name'))
call self.assert_equal(len(candidates), len(s:list))
endfunction"}}}

function! s:tc.test_source_change_candidate()"{{{
let source = self.get('s:source')
let candidates = source.change_candidates('', {'input' : 'hoge'})
call self.assert_equal(type([]), type(candidates))
call self.assert(has_key(candidates[0], 'word'))
call self.assert(has_key(candidates[0], 'source'))
call self.assert(has_key(candidates[0], 'kind'))
call self.assert(has_key(candidates[0], 'action__name'))
call self.assert(has_key(candidates[0], 'action__is_new'))
call self.assert_equal(len(candidates), len(s:list))
endfunction"}}}

unlet s:tc

0 comments on commit e14460e

Please sign in to comment.