1 |
|
2 | should = require 'should'
|
3 | mecano = if process.env.MECANO_COV then require '../lib-cov/mecano' else require '../lib/mecano'
|
4 | test = require './test'
|
5 |
|
6 | describe 'extract', ->
|
7 |
|
8 | scratch = test.scratch @
|
9 |
|
10 | it 'should see extension .tgz', (next) ->
|
11 |
|
12 | mecano.extract
|
13 | source: "#{__dirname}/../resources/a_dir.tgz"
|
14 | destination: scratch
|
15 | , (err, extracted) ->
|
16 | should.not.exist err
|
17 | extracted.should.eql 1
|
18 |
|
19 |
|
20 |
|
21 | mecano.extract
|
22 | source: "#{__dirname}/../resources/a_dir.tgz"
|
23 | destination: scratch
|
24 | , (err, extracted) ->
|
25 | should.not.exist err
|
26 | extracted.should.eql 1
|
27 | next()
|
28 |
|
29 | it 'should see extension .zip', (next) ->
|
30 |
|
31 | mecano.extract
|
32 | source: "#{__dirname}/../resources/a_dir.zip"
|
33 | destination: scratch
|
34 | , (err, extracted) ->
|
35 | should.not.exist err
|
36 | extracted.should.eql 1
|
37 |
|
38 |
|
39 |
|
40 | mecano.extract
|
41 | source: "#{__dirname}/../resources/a_dir.zip"
|
42 | destination: scratch
|
43 | , (err, extracted) ->
|
44 | should.not.exist err
|
45 | extracted.should.eql 1
|
46 | next()
|
47 |
|
48 | it 'should validate a created file', (next) ->
|
49 |
|
50 | mecano.extract
|
51 | source: "#{__dirname}/../resources/a_dir.tgz"
|
52 | destination: scratch
|
53 | creates: "#{scratch}/oh_no"
|
54 | , (err, extracted) ->
|
55 | err.message.should.eql "Failed to create 'oh_no'"
|
56 |
|
57 | mecano.extract
|
58 | source: "#{__dirname}/../resources/a_dir.tgz"
|
59 | destination: scratch
|
60 | creates: "#{scratch}/a_dir"
|
61 | , (err, extracted) ->
|
62 | should.not.exist err
|
63 | extracted.should.eql 1
|
64 | next()
|
65 |
|
66 | it 'should # option # not_if_exists', (next) ->
|
67 |
|
68 | mecano.extract
|
69 | source: "#{__dirname}/../resources/a_dir.tgz"
|
70 | destination: scratch
|
71 | not_if_exists: __dirname
|
72 | , (err, extracted) ->
|
73 | should.not.exist err
|
74 | extracted.should.eql 0
|
75 | next()
|
76 |
|
77 | it 'should # error # extension', (next) ->
|
78 | mecano.extract
|
79 | source: __filename
|
80 | , (err, extracted) ->
|
81 | err.message.should.eql 'Unsupported extension, got ".coffee"'
|
82 | next()
|
83 |
|
84 |
|