Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial changes for e2e testing framework #553

Merged
merged 2 commits into from
Feb 19, 2021

Conversation

patilpankaj212
Copy link
Contributor

@patilpankaj212 patilpankaj212 commented Feb 17, 2021

Added tests for init command.

@patilpankaj212 patilpankaj212 marked this pull request as draft February 17, 2021 12:28
@devang-gaur
Copy link
Contributor

One test case I can think of :

  1. execute terrascan init. Check if the timestamp of the downloaded $HOME/.terrascan directory. Let's say it was created at time t1.

  2. execute terrascan init again. Check if the timestamp of the downloaded $HOME/.terrascan directory. Let's say it was created at time t2.

  3. Assert that t2 > t1. This verifies that $HOME/.terrascan is downloaded fresh everytime terrascan init is run.

@patilpankaj212 patilpankaj212 force-pushed the testing-framework branch 2 times, most recently from cce5a7b to 0e93a3d Compare February 18, 2021 06:09
@codecov
Copy link

codecov bot commented Feb 18, 2021

Codecov Report

Merging #553 (f906aed) into master (10d6706) will increase coverage by 0.33%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
+ Coverage   76.98%   77.32%   +0.33%     
==========================================
  Files          98       97       -1     
  Lines        2368     2381      +13     
==========================================
+ Hits         1823     1841      +18     
+ Misses        402      398       -4     
+ Partials      143      142       -1     
Impacted Files Coverage Δ
pkg/iac-providers/helm/v3/load-dir.go 85.51% <0.00%> (-0.10%) ⬇️
pkg/iac-providers/kubernetes/v1/load-file.go 76.00% <0.00%> (ø)
cmd/terrascan/main.go
pkg/iac-providers/terraform/commons/load-dir.go 85.52% <0.00%> (+0.39%) ⬆️
pkg/iac-providers/kustomize/v3/load-dir.go 74.00% <0.00%> (+0.92%) ⬆️
pkg/runtime/validate.go 86.00% <0.00%> (+3.50%) ⬆️
pkg/iac-providers/terraform/commons/load-file.go 92.00% <0.00%> (+17.00%) ⬆️

@patilpankaj212 patilpankaj212 force-pushed the testing-framework branch 2 times, most recently from 2cef957 to 2434d9e Compare February 18, 2021 17:21
@patilpankaj212 patilpankaj212 marked this pull request as ready for review February 18, 2021 17:30
})
It("should error out and exit with status code 1", func() {
session = runInitCommand(terrascanBinaryPath, outWriter, errWriter, 1)
helper.ContainsErrorSubString(session, "invalid/path: no such file or directory")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make changes to return a more specific error message for erranous rego subdir.
Not to be fixed in this PR though.

})
})

func runInitCommand(terrascanBinaryPath string, outWriter, errWriter io.Writer, exitCode int) *gexec.Session {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these three functions can be moved to helper or test_util file

Copy link
Contributor

@devang-gaur devang-gaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor change to move the functions. everything else LGTM.

@sonarcloud
Copy link

sonarcloud bot commented Feb 19, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kanchwala-yusuf kanchwala-yusuf dismissed devang-gaur’s stale review February 19, 2021 14:31

review comments accommodated

@kanchwala-yusuf kanchwala-yusuf merged commit bbe97ce into tenable:master Feb 19, 2021
@patilpankaj212 patilpankaj212 deleted the testing-framework branch April 7, 2021 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants