-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from looker-open-source/fabble/incremental
Incremental linting
- Loading branch information
Showing
25 changed files
with
726 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lams-exemptions.ndjson |
90 changes: 90 additions & 0 deletions
90
__tests__/dummy-projects/27-output-add-exemptions/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const lams = require('../../../index.js') | ||
const mocks = require('../../../lib/mocks.js') | ||
const path= require('path') | ||
const defaultTestingOptions = {reporting:"no", cwd:__dirname} | ||
require('../../../lib/expect-to-contain-message'); | ||
const log = x=>console.log(x) | ||
const testProjectName = __dirname.split(path.sep).slice(-1)[0]; | ||
const fs = require("node:fs/promises") | ||
const expectedOutput = '{"rule":"K1","location":"model:test/view:bad"}\n'; | ||
describe('Projects', () => { | ||
describe(testProjectName, () => { | ||
let {spies, process, console} = mocks() | ||
let messages1, messages2, output1, output2 | ||
beforeAll( async () => { | ||
const options = { | ||
...defaultTestingOptions, | ||
output: "add-exemptions" | ||
} | ||
const outputPath = path.resolve(__dirname,"lams-exemptions.ndjson") | ||
try{await fs.rm(outputPath, {force:true})}catch(e){} | ||
messages1 = {messages: await lams(options,{process, console})} | ||
output1 = await fs.readFile(outputPath,{encoding:"utf8"}) | ||
messages2 = {messages: await lams(options,{process, console})} | ||
output2 = await fs.readFile(outputPath,{encoding:"utf8"}) | ||
}) | ||
it("should not error out", ()=> { | ||
expect(console.error).not.toHaveBeenCalled() | ||
}); | ||
it("it should not contain any unexpected parser (P0) errors", ()=> { | ||
expect(messages1).not.toContainMessage({ | ||
rule: "P0", | ||
level: "error" | ||
}); | ||
expect(messages2).not.toContainMessage({ | ||
rule: "P0", | ||
level: "error" | ||
}); | ||
}); | ||
it("it should not contain any parser syntax (P1) errors", ()=> { | ||
expect(messages1).not.toContainMessage({ | ||
rule: "P1", | ||
level: "error" | ||
}); | ||
expect(messages2).not.toContainMessage({ | ||
rule: "P1", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("run 1 should match K1 (1 match, 0 exempt, 1 error)", ()=> { | ||
expect(messages1).toContainMessage({ | ||
rule: "K1", | ||
level: "info", | ||
description: "Rule K1 summary: 1 matches, 0 matches exempt, and 1 errors" | ||
}); | ||
}); | ||
|
||
it("run 1 should error on K1", ()=> { | ||
expect(messages1).toContainMessage({ | ||
rule: "K1", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("run 1 should output the expected ndjson", ()=> { | ||
expect(output1).toEqual(expectedOutput); | ||
}); | ||
|
||
it("run 2 should match K1 (1 match, 1 exempt, 0 errors)", ()=> { | ||
expect(messages2).toContainMessage({ | ||
rule: "K1", | ||
level: "info", | ||
description: "Rule K1 summary: 1 matches, 1 matches exempt, and 0 errors" | ||
}); | ||
}); | ||
|
||
it("run 2 not should error on K1", ()=> { | ||
expect(messages2).not.toContainMessage({ | ||
rule: "K1", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("run 2 should output the (same) expected ndjson", ()=> { | ||
expect(output2).toEqual(expectedOutput); | ||
}); | ||
|
||
|
||
}); | ||
}); |
2 changes: 2 additions & 0 deletions
2
__tests__/dummy-projects/27-output-add-exemptions/manifest.lkml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#LAMS | ||
#rule: K1 {} |
7 changes: 7 additions & 0 deletions
7
__tests__/dummy-projects/27-output-add-exemptions/test.model.lkml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
explore: bad {} | ||
|
||
view: bad { | ||
sql_table_name: foo ;; | ||
dimension: not_a_pk {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.