aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/repository/local.lux
blob: 9be4a53c8e82d6a33cd7eaf87c50a24dfd436167 (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
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try (.use "[1]#[0]" functor)]
    [concurrency
     ["[0]" async]]]
   [data
    ["[0]" binary (.use "[1]#[0]" equivalence)]
    [text
     [encoding
      ["[0]" utf8]]]]
   [math
    ["[0]" random]]
   [world
    ["[0]" file]
    ["[0]" environment
     ["program" /]
     ["[1]" \\parser]]]
   [test
    ["[0]" unit]
    ["_" property (.only Test)]]]]
 [\\program
  ["[0]" /]])

(def .public test
  Test
  (<| (_.covering /._)
      (do [! random.monad]
        [/ (random.upper_cased 1)
         home (random.lower_cased 10)
         working_directory (random.lower_cased 10)
         .let [fs (file.mock /)
               program (program.async (program.mock environment.empty home working_directory))
               repo (/.repository program fs)]

         uri (random.lower_cased 10)
         expected (of ! each (of utf8.codec encoded)
                      (random.lower_cased 10))]
        (all _.and
             (in (do async.monad
                   [before_upload (of repo download uri)
                    _ (of repo upload uri expected)
                    actual (of repo download uri)]
                   (unit.coverage [/.repository]
                     (and (when before_upload
                            {try.#Success _} false
                            {try.#Failure _} true)
                          (|> actual
                              (try#each (binary#= expected))
                              (try.else false))))))
             ))))