File: test_hide_continue.bats

package info (click to toggle)
git-secret 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,724 kB
  • sloc: sh: 4,580; makefile: 162; xml: 31; python: 22
file content (52 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bats

load _test_base

FILE_TO_HIDE="$TEST_DEFAULT_FILENAME"
FILE_TO_HIDE2="$TEST_SECOND_FILENAME"
FILE_CONTENTS="hidden content юникод"


function setup {
  install_fixture_key "$TEST_DEFAULT_USER"

  set_state_initial
  set_state_git
  set_state_secret_init
  set_state_secret_tell "$TEST_DEFAULT_USER"
  set_state_secret_add "$FILE_TO_HIDE" "$FILE_CONTENTS"
  set_state_secret_add "$FILE_TO_HIDE2" "$FILE_CONTENTS"
}


function teardown {
  rm "$FILE_TO_HIDE"
  rm "$FILE_TO_HIDE2"

  uninstall_fixture_key "$TEST_DEFAULT_USER"
  unset_current_state
}


@test "run 'hide -F' with missing input file" {
  mv "$FILE_TO_HIDE" "$FILE_TO_HIDE.was"  # move the first file out of the way
  run git secret hide -F

  #echo "# output of 'git secret hide -F' is: $output" >&3

  # Command must execute normally:
  [ "$status" -eq 0 ]

  # secret file for missing file should not be created:
  local encrypted_file
  encrypted_file=$(_get_encrypted_filename "$FILE_TO_HIDE")
  [ ! -f "$encrypted_file" ]

  # this secret file should be created:
  local encrypted_file2
  encrypted_file2=$(_get_encrypted_filename "$FILE_TO_HIDE2")
  [ -f "$encrypted_file2" ]

  # put back first file so teardown() succeeds
  mv "$FILE_TO_HIDE.was" "$FILE_TO_HIDE"
}