|
16 | 16 | #
|
17 | 17 |
|
18 | 18 | load '../../libs/dataplaneapi'
|
| 19 | +load '../../libs/debug' |
19 | 20 | load '../../libs/get_json_path'
|
20 | 21 | load '../../libs/haproxy_config_setup'
|
21 | 22 | load '../../libs/resource_client'
|
22 | 23 | load '../../libs/version'
|
23 | 24 |
|
24 | 25 | load 'utils/_helpers'
|
25 | 26 |
|
26 |
| -@test "cache: Replace one cache" { |
27 |
| - resource_put "$_CACHE_BASE_PATH/test_cache" "data/cache_same_name.json" |
| 27 | +@test "cache: All Cache Tests" { |
| 28 | + resource_post "$_CACHE_BASE_PATH" "data/cache.json" |
| 29 | + assert_equal "$SC" 202 |
| 30 | + |
| 31 | + resource_get "$_CACHE_BASE_PATH/cache_created" |
28 | 32 | assert_equal "$SC" 200
|
29 | 33 |
|
| 34 | + assert_equal "cache_created" "$(get_json_path "$BODY" ".name")" |
| 35 | + assert_equal 1 "$(get_json_path "$BODY" ".max_object_size")" |
| 36 | + assert_equal 1000 "$(get_json_path "$BODY" ".total_max_size")" |
| 37 | + |
| 38 | + resource_post "$_CACHE_BASE_PATH" "data/cache_same_name.json" |
| 39 | + assert_equal "$SC" 409 |
| 40 | + |
| 41 | + resource_post "$_CACHE_BASE_PATH" "data/cache_unvalid.json" |
| 42 | + assert_equal "$SC" 400 |
| 43 | + |
| 44 | + |
| 45 | + resource_delete "$_CACHE_BASE_PATH/test_cache2" |
| 46 | + assert_equal "$SC" 202 |
| 47 | + |
| 48 | + resource_get "$_CACHE_BASE_PATH/test_cache2" |
| 49 | + assert_equal "$SC" 404 |
| 50 | + |
| 51 | + resource_delete "$_CACHE_BASE_PATH/i_am_not_here" |
| 52 | + assert_equal "$SC" 404 |
| 53 | + |
| 54 | + resource_get "$_CACHE_BASE_PATH/test_cache" |
| 55 | + assert_equal "$SC" 200 |
| 56 | + assert_equal "test_cache" "$(get_json_path "$BODY" ".name")" |
| 57 | + assert_equal 60 "$(get_json_path "$BODY" ".max_age")" |
| 58 | + assert_equal 8 "$(get_json_path "$BODY" ".max_object_size")" |
| 59 | + assert_equal 1024 "$(get_json_path "$BODY" ".total_max_size")" |
| 60 | + |
| 61 | + |
| 62 | + resource_get "$_CACHE_BASE_PATH/i_am_not_here" |
| 63 | + assert_equal "$SC" 404 |
| 64 | + |
| 65 | + resource_get "$_CACHE_BASE_PATH" |
| 66 | + assert_equal "$SC" 200 |
| 67 | + assert_equal 2 "$(get_json_path "$BODY" ". | length")" |
| 68 | + |
| 69 | + resource_put "$_CACHE_BASE_PATH/test_cache" "data/cache_same_name.json" |
| 70 | + assert_equal "$SC" 202 |
| 71 | + |
30 | 72 | resource_get "$_CACHE_BASE_PATH/test_cache"
|
31 | 73 | assert_equal "$SC" 200
|
32 | 74 | assert_equal "test_cache" "$(get_json_path "$BODY" ".name")"
|
33 | 75 | assert_equal 1 "$(get_json_path "$BODY" ".max_object_size")"
|
34 | 76 | assert_equal 1000 "$(get_json_path "$BODY" ".total_max_size")"
|
35 |
| -} |
36 | 77 |
|
37 |
| - |
38 |
| -@test "cache: Fail replacing cache that doesn't exist" { |
39 | 78 | resource_put "$_CACHE_BASE_PATH/i_am_not_here" "data/cache_same_name.json"
|
40 | 79 | assert_equal "$SC" 404
|
41 |
| -} |
42 | 80 |
|
43 |
| -@test "cache: Fail creating cache that isn't valid" { |
44 | 81 | resource_put "$_CACHE_BASE_PATH/test_cache" "data/cache_unvalid.json"
|
45 | 82 | assert_equal "$SC" 400
|
| 83 | + |
46 | 84 | }
|
0 commit comments