aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/aedifex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/spec/aedifex/repository.lux49
1 files changed, 49 insertions, 0 deletions
diff --git a/stdlib/source/spec/aedifex/repository.lux b/stdlib/source/spec/aedifex/repository.lux
new file mode 100644
index 000000000..613bbd407
--- /dev/null
+++ b/stdlib/source/spec/aedifex/repository.lux
@@ -0,0 +1,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))))
+ ))))