aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/aedifex/repository.lux
blob: 250bd3d015c689db1086308b3710bf938f1a0ccb (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
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]]
   [control
    ["." try (#+ Try)]
    [concurrency
     ["." promise (#+ Promise)]]]
   [data
    ["." binary
     {[0 #test]
      ["_#" /]}]]
   [math
    ["." random]]]
  {#program
   ["." /
    ["#." remote]
    ["/#" // #_
     ["#." artifact (#+ Artifact)
      ["#/." extension]]]]}
  {#test
   ["_." // #_
    ["#." artifact]]})

(def: #export (spec valid_artifact invalid_artifact subject)
  (-> Artifact Artifact (/.Repository Promise) Test)
  (do random.monad
    [expected (_binary.random 100)]
    (wrap ($_ _.and'
              (do promise.monad
                [#let [uri/good (/remote.uri valid_artifact //artifact/extension.lux_library)]
                 upload!/good (\ subject upload uri/good expected)
                 download!/good (\ subject download uri/good)

                 #let [uri/bad (/remote.uri invalid_artifact //artifact/extension.lux_library)]
                 upload!/bad (\ subject upload uri/bad expected)
                 download!/bad (\ subject download uri/bad)]
                (_.cover' [/.Repository]
                          (and (case [upload!/good download!/good]
                                 [(#try.Success _) (#try.Success actual)]
                                 (\ binary.equivalence = expected actual)

                                 _
                                 false)
                               (case [upload!/bad download!/bad]
                                 [(#try.Failure _) (#try.Failure _)]
                                 true
                                 
                                 _
                                 false))))
              ))))