blob: 613bbd4076b309a623fc2f0c8ce7193d4212f63e (
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)]
(_.claim [/.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))))
))))
|