aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/command/deps.lux
blob: 87a3e1731cfcbf84f9aac85ec00d137992bf5721 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]
     ["." predicate]]
    [control
     ["." try]
     [concurrency
      ["." async]]
     [parser
      ["." environment]]]
    [data
     ["." text ("#\." equivalence)
      ["%" format (#+ format)]
      [encoding
       ["." utf8]]]
     [collection
      ["." dictionary]
      ["." set]]
     [format
      ["." xml]]]
    [math
     ["." random (#+ Random)]]
    [world
     ["." program]
     ["." file]]]]
  ["." // #_
   ["@." version]
   ["$/#" // #_
    ["#." package]
    ["#." artifact]
    ["#." dependency #_
     ["#/." resolution]]]]
  [\\program
   ["." /
    ["/#" // #_
     ["#." clean]
     ["/#" // #_
      ["#" profile]
      ["#." action]
      ["#." pom]
      ["#." package]
      ["#." artifact
       ["#/." type]]
      ["#." dependency
       ["#/." resolution]
       ["#/." deployment]
       ["#/." status]]
      ["#." repository
       ["#/." origin]
       ["#/." local]]]]]])

(def: .public test
  Test
  (<| (_.covering /._)
      (do random.monad
        [home (random.ascii/alpha 5)
         working_directory (random.ascii/alpha 5)

         dependee_artifact $///artifact.random
         depender_artifact (random.only (predicate.complement
                                         (\ ///artifact.equivalence = dependee_artifact))
                                        $///artifact.random)

         [_ dependee_package] $///package.random
         [_ depender_package] $///package.random

         .let [dependee {#///dependency.artifact dependee_artifact
                         #///dependency.type ///artifact/type.lux_library}
               depender {#///dependency.artifact depender_artifact
                         #///dependency.type ///artifact/type.lux_library}

               dependee_pom (|> (\ ///.monoid identity)
                                (with@ #///.identity (#.Some dependee_artifact))
                                ///pom.write
                                try.trusted)
               depender_pom (|> (\ ///.monoid identity)
                                (with@ #///.identity (#.Some depender_artifact))
                                (with@ #///.dependencies (set.of_list ///dependency.hash (list dependee)))
                                ///pom.write
                                try.trusted)
               
               dependee_package (|> dependee_package
                                    (with@ #///package.origin (#///repository/origin.Remote ""))
                                    (with@ #///package.pom [dependee_pom
                                                            (|> dependee_pom (\ xml.codec encoded) (\ utf8.codec encoded))
                                                            #///dependency/status.Unverified]))
               depender_package (|> depender_package
                                    (with@ #///package.origin (#///repository/origin.Remote ""))
                                    (with@ #///package.pom [depender_pom
                                                            (|> depender_pom (\ xml.codec encoded) (\ utf8.codec encoded))
                                                            #///dependency/status.Unverified]))

               fs (file.mock (\ file.default separator))
               program (program.async (program.mock environment.empty home working_directory))]]
        (in (do async.monad
              [verdict (do ///action.monad
                         [.let [console (@version.echo "")
                                local (///repository/local.repository program fs)]
                          pre (|> ///dependency/resolution.empty
                                  (dictionary.has dependee dependee_package)
                                  (///dependency/deployment.all local))
                          post (|> (\ ///.monoid identity)
                                   (with@ #///.dependencies (set.of_list ///dependency.hash (list dependee depender)))
                                   (/.do! console local
                                          (list (///repository.mock ($///dependency/resolution.single depender_artifact depender_package)
                                                                    []))
                                          (function (_ url)
                                            (///repository.mock $///dependency/resolution.nope []))))

                          .let [had_dependee_before!
                                (set.member? pre dependee_artifact)

                                lacked_depender_before!
                                (not (set.member? pre depender_artifact))

                                had_dependee_after!
                                (dictionary.key? post dependee)
                                
                                had_depender_after!
                                (dictionary.key? post depender)]]
                         (in (and had_dependee_before!
                                  lacked_depender_before!
                                  
                                  had_dependee_after!
                                  had_depender_after!)))]
              (_.cover' [/.do!]
                        (try.else false verdict)))))))