File: ftpsync.bats

package info (click to toggle)
archvsync 20180513%2Bnmu1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 236 kB
  • sloc: sh: 883; makefile: 80
file content (47 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bats

load helper

@test "run ftpsync" {
  run_ftpsync sync:archive:default
  [[ $status -eq 0 ]]

  ! [[ -f $BATS_TEST_OWN_LOGDIR/ftpsync-default.log ]]
  ! [[ -f $BATS_TEST_OWN_LOGDIR/rsync-ftpsync-default.log ]]
  ! [[ -f $BATS_TEST_OWN_LOGDIR/rsync-ftpsync-default.error ]]

  [[ -s $BATS_TEST_OWN_OUTDIR/project/trace/localhost ]]
  [[ -s $BATS_TEST_OWN_OUTDIR/project/trace/master.example.com ]]
  grep 'Archive serial: 2017091804' $BATS_TEST_OWN_OUTDIR/project/trace/localhost
  grep -v 'Trigger:' $BATS_TEST_OWN_OUTDIR/project/trace/localhost
}

@test "run ftpsync, ssh command" {
  SSH_ORIGINAL_COMMAND="sync:archive:default" run_ftpsync
  [[ $status -eq 0 ]]

  ! [[ -f $BATS_TEST_OWN_LOGDIR/ftpsync-default.log ]]
  ! [[ -f $BATS_TEST_OWN_LOGDIR/rsync-ftpsync-default.log ]]
  ! [[ -f $BATS_TEST_OWN_LOGDIR/rsync-ftpsync-default.error ]]

  [[ -s $BATS_TEST_OWN_OUTDIR/project/trace/localhost ]]
  [[ -s $BATS_TEST_OWN_OUTDIR/project/trace/master.example.com ]]
  grep 'Archive serial: 2017091804' $BATS_TEST_OWN_OUTDIR/project/trace/localhost
  grep 'Trigger: ssh' $BATS_TEST_OWN_OUTDIR/project/trace/localhost
}

@test "run ftpsync with non-existant archive" {
  run bin/ftpsync sync:archive:
  [[ $status -eq 78 ]]
}

@test "run ftpsync with non-existant archive, ssh comman" {
  SSH_ORIGINAL_COMMAND="sync:archive:" run bin/ftpsync
  [[ $status -eq 78 ]]
}

@test "run ftpsync with non-default trigger" {
  run_ftpsync -T test sync:archive:default
  [[ $status -eq 0 ]]
  grep 'Trigger: test' $BATS_TEST_OWN_OUTDIR/project/trace/localhost
}