Skip to content

Commit

Permalink
Remove lib/Program.ts (#2948)
Browse files Browse the repository at this point in the history
It was unused.
  • Loading branch information
mattnibs authored Jan 5, 2024
1 parent 496835e commit 10f1621
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 123 deletions.
69 changes: 0 additions & 69 deletions apps/zui/src/js/lib/Program.ts

This file was deleted.

54 changes: 0 additions & 54 deletions apps/zui/src/js/models/program.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {createField, createRecord} from "@brimdata/zed-js"
import {joinParts, parallelizeProcs, splitParts} from "../lib/Program"
import program from "./program"

describe("excluding and including", () => {
Expand Down Expand Up @@ -231,59 +230,6 @@ describe("#hasAnalytics()", () => {
})
})

describe("Get Parts of Program", () => {
const script = 'md5=="123" _path=="files" | count() by md5 | sort -r | head 1'

test("get filter part", () => {
expect(splitParts(script)[0]).toBe('md5=="123" _path=="files"')
})

test("get filter part when none", () => {
expect(splitParts("* | count()")[0]).toBe("*")
})

test("get proc part", () => {
expect(splitParts(script)[1]).toBe("count() by md5 | sort -r | head 1")
})

test("get proc part when none", () => {
expect(splitParts('_path=="files"')[1]).toEqual("")
})
})

describe("Join Parts of Program", () => {
const filter = 'md5=="123"'
const proc = "count() by _path"

test("#joinParts", () => {
expect(joinParts(filter, proc)).toBe('md5=="123" | count() by _path')
})

test("#joinParts when empty filter", () => {
expect(joinParts("", proc)).toBe("* | count() by _path")
})
})

describe("Parallelizing multiple programs", () => {
const a = 'md5=="123" | count()'
const b = 'md5=="123" | head 5'
const c = 'md5=="123" | count() by _path'

test("#parallelizeProcs when programs have same filter", () => {
expect(parallelizeProcs([a, b, c])).toEqual(
'md5=="123" | fork ( => count() => head 5 => count() by _path )'
)
})

test("#parallelizeProcs when programs do not have same filter", () => {
expect(() => {
parallelizeProcs([a, b, c, '_path=="conn"'])
}).toThrow(
'Filters must be the same in all programs: md5=="123", md5=="123", md5=="123", _path=="conn"'
)
})
})

describe("extracting the first filter", () => {
test("*", () => {
expect(program("*").filter()).toEqual("*")
Expand Down

0 comments on commit 10f1621

Please sign in to comment.