summaryrefslogtreecommitdiffstats
path: root/tests/integration/items.bats
blob: 22a4c73c74d7cfca843307a3eacadc2c8ed9f3c2 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bats

load "helpers/settings"

TESTSUITE="Items"

setup() {
  ./occ news:feed:add "$user" "https://github.com/nextcloud/news/releases.atom" --title "Something-${BATS_SUITE_TEST_NUMBER}"

  TAG=$(curl --silent "https://api.github.com/repos/nextcloud/news/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
  ID=$(./occ news:feed:list 'admin' | grep 'github\.com' -1  | head -1 | grep -oE '[0-9]*')
}

teardown() {
  if [ -n "$ID" ]; then
    ./occ news:feed:delete "$user" "$ID"
  fi
}

@test "[$TESTSUITE] List 200 items in feed" {
  run ./occ news:item:list-feed "$user" "$ID" --limit 200
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in feed list"
    return $ret_status
  fi
}

@test "[$TESTSUITE] List all items in feed" {
  run ./occ news:item:list-feed "$user" "$ID" --limit 0
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in feed list"
    return $ret_status
  fi
}

@test "[$TESTSUITE] List 200 items in folder" {
  run ./occ news:item:list-folder "$user" --limit 200
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in folder list"
    return $ret_status
  fi
}

@test "[$TESTSUITE] List all items in folder" {
  run ./occ news:item:list-folder "$user" --limit 0
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in folder list"
    return $ret_status
  fi
}

@test "[$TESTSUITE] List 200 items" {
  run ./occ news:item:list "$user" --limit 200
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in list"
    return $ret_status
  fi
}

@test "[$TESTSUITE] List all items" {
  run ./occ news:item:list "$user" --limit 0
  [ "$status" -eq 0 ]

  if ! echo "$output" | grep "$TAG"; then
    ret_status=$?
    echo "Release not found in list"
    return $ret_status
  fi
}