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

(def: #export (spec valid-identity valid-artifact invalid-identity invalid-artifact subject)
  (-> /.Identity Artifact /.Identity Artifact (/.Repository Promise) Test)
  (do random.monad
    [expected (_binary.random 100)]
    (wrap ($_ _.and'
              (do promise.monad
                [upload!/good (\ subject upload valid-identity valid-artifact //artifact/extension.lux-library expected)
                 download!/good (\ subject download valid-artifact //artifact/extension.lux-library)

                 upload!/bad (\ subject upload invalid-identity invalid-artifact //artifact/extension.lux-library expected)
                 download!/bad (\ subject download invalid-artifact //artifact/extension.lux-library)]
                (_.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))))
              ))))