-
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 #191 from looker-open-source/exempt-enhancements
Exempt enhancements
- Loading branch information
Showing
16 changed files
with
181 additions
and
36 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
5 changes: 5 additions & 0 deletions
5
__tests__/dummy-projects/30-disallow-exemptions/bad.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,5 @@ | ||
# LAMS | ||
# rule_exemptions:{ | ||
# require_persist_for: "Who needs persist_for???" | ||
# really_require_persist_for: "Who really needs persist_for???" | ||
# } |
2 changes: 2 additions & 0 deletions
2
__tests__/dummy-projects/30-disallow-exemptions/good.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,2 @@ | ||
|
||
persist_for: "1 hour" |
67 changes: 67 additions & 0 deletions
67
__tests__/dummy-projects/30-disallow-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,67 @@ | ||
let {testName, lams, options, mocks} = require('../../../lib/test-commons.js')(__dirname,{dirnameOffset:-1}) | ||
|
||
options = {...options, manifest:`./manifest.lams-lkml`} | ||
|
||
describe('Projects', () => { | ||
describe(testName, () => { | ||
let {spies, process, console} = mocks() | ||
let messages | ||
beforeAll( async () => { | ||
messages = await lams(options,{process, console}); | ||
}) | ||
it("should not error out", ()=> { | ||
expect(console.error).not.toHaveBeenCalled() | ||
}); | ||
it("it should not contain any unexpected parser (P0) errors", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "P0", | ||
level: "error" | ||
}); | ||
}); | ||
it("it should not contain any parser syntax (P1) errors", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "P1", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("it should provide correct aggregate info for require_persist_for (2 match, 1 exempt, 0 error)", ()=> { | ||
expect({messages}).toContainMessage({ | ||
rule: "require_persist_for", | ||
level: "info", | ||
description: "Rule require_persist_for summary: 2 matches, 1 matches exempt, and 0 errors" | ||
}); | ||
}); | ||
|
||
it("it should not error on require_persist_for", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "require_persist_for", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("it should provide correct aggregate info for really_require_persist_for (2 match, 0 exempt, 1 error)", ()=> { | ||
expect({messages}).toContainMessage({ | ||
rule: "really_require_persist_for", | ||
level: "info", | ||
description: "Rule really_require_persist_for summary: 2 matches, 0 matches exempt, and 1 errors" | ||
}); | ||
}); | ||
|
||
it("it should error on really_require_persist_for for model bad", ()=> { | ||
expect({messages}).toContainMessage({ | ||
rule: "really_require_persist_for", | ||
location: "model:bad", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("it should not error on really_require_persist_for for model good", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "really_require_persist_for", | ||
location: "model:good", | ||
level: "error" | ||
}); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
__tests__/dummy-projects/30-disallow-exemptions/manifest.lams-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,11 @@ | ||
|
||
rule: require_persist_for { | ||
match: "$.model.*" | ||
expr_rule: (!== ::match:persist_for undefined) ;; | ||
} | ||
|
||
rule: really_require_persist_for { | ||
match: "$.model.*" | ||
expr_rule: (!== ::match:persist_for undefined) ;; | ||
allow_exemptions: no | ||
} |
10 changes: 10 additions & 0 deletions
10
__tests__/dummy-projects/31-compact-exemptions/exempt.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,10 @@ | ||
|
||
explore: bad {} | ||
|
||
explore: ex1 { | ||
#LAMS exempt: explore_description {} | ||
} | ||
|
||
explore: ex2 { | ||
#LAMS exempt: explore_description {why: "Because"} | ||
} |
36 changes: 36 additions & 0 deletions
36
__tests__/dummy-projects/31-compact-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,36 @@ | ||
let {testName, lams, options, mocks} = require('../../../lib/test-commons.js')(__dirname,{dirnameOffset:-1}) | ||
|
||
options = {...options, manifest:`./manifest.lams-lkml`} | ||
|
||
describe('Projects', () => { | ||
describe(testName, () => { | ||
let {spies, process, console} = mocks() | ||
let messages | ||
beforeAll( async () => { | ||
messages = await lams(options,{process, console}); | ||
}) | ||
it("should not error out", ()=> { | ||
expect(console.error).not.toHaveBeenCalled() | ||
}); | ||
it("it should not contain any unexpected parser (P0) errors", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "P0", | ||
level: "error" | ||
}); | ||
}); | ||
it("it should not contain any parser syntax (P1) errors", ()=> { | ||
expect({messages}).not.toContainMessage({ | ||
rule: "P1", | ||
level: "error" | ||
}); | ||
}); | ||
|
||
it("it should provide correct aggregate info for explore_description (3 match, 2 exempt, 1 error)", ()=> { | ||
expect({messages}).toContainMessage({ | ||
rule: "explore_description", | ||
level: "info", | ||
description: "Rule explore_description summary: 3 matches, 2 matches exempt, and 1 errors" | ||
}); | ||
}); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
__tests__/dummy-projects/31-compact-exemptions/manifest.lams-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,5 @@ | ||
|
||
rule: explore_description { | ||
match: "$.model.*.explore.*" | ||
expr_rule: (!== ::match:description undefined) ;; | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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