-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathuseCellar.test.ts
More file actions
34 lines (25 loc) · 1.22 KB
/
useCellar.test.ts
File metadata and controls
34 lines (25 loc) · 1.22 KB
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
import { assertEquals, assertRejects } from "deno/assert/mod.ts"
import SemVer, * as semver from "../utils/semver.ts"
import { useTestConfig } from "./useTestConfig.ts"
import useCellar from "./useCellar.ts"
Deno.test("useCellar.resolve()", async () => {
useTestConfig()
const pkg = { project: "python.org", version: new SemVer("3.11.3") }
const path = useCellar().shelf(pkg.project).join(`v${pkg.version}`).mkdir('p')
path.join("cant-be-empty").touch()
const installation = { pkg, path }
await useCellar().resolve(installation)
await useCellar().resolve(installation.pkg)
await useCellar().resolve({ project: "python.org", constraint: new semver.Range("^3") })
await useCellar().resolve(installation.path)
await assertRejects(() => useCellar().resolve({ project: "python.org", constraint: new semver.Range("@300")}))
})
Deno.test("useCellar.has()", async () => {
useTestConfig()
const pkg = { project: "beyondgrep.com", version: new SemVer("3.6.0") }
assertEquals(await useCellar().has(pkg), undefined)
const path = useCellar().shelf(pkg.project).join(`v${pkg.version}`).mkdir('p')
path.join("cant-be-empty").touch()
const installation = { pkg, path }
assertEquals(await useCellar().has(pkg), installation)
})