mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
Simplify tests by using GinkgoT().TempDir() (#1265)
This commit is contained in:
parent
09b914371e
commit
ef1a35faf9
2 changed files with 4 additions and 13 deletions
|
@ -17,7 +17,6 @@ package gosec_test
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -45,10 +44,8 @@ var _ = Describe("Analyzer", func() {
|
||||||
Context("when processing a package", func() {
|
Context("when processing a package", func() {
|
||||||
It("should not report an error if the package contains no Go files", func() {
|
It("should not report an error if the package contains no Go files", func() {
|
||||||
analyzer.LoadRules(rules.Generate(false).RulesInfo())
|
analyzer.LoadRules(rules.Generate(false).RulesInfo())
|
||||||
dir, err := os.MkdirTemp("", "empty")
|
dir := GinkgoT().TempDir()
|
||||||
defer os.RemoveAll(dir)
|
err := analyzer.Process(buildTags, dir)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
|
||||||
err = analyzer.Process(buildTags, dir)
|
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
_, _, errors := analyzer.Report()
|
_, _, errors := analyzer.Report()
|
||||||
Expect(errors).To(BeEmpty())
|
Expect(errors).To(BeEmpty())
|
||||||
|
|
|
@ -17,14 +17,8 @@ var _ = Describe("Helpers", func() {
|
||||||
Context("when listing package paths", func() {
|
Context("when listing package paths", func() {
|
||||||
var dir string
|
var dir string
|
||||||
JustBeforeEach(func() {
|
JustBeforeEach(func() {
|
||||||
var err error
|
dir = GinkgoT().TempDir()
|
||||||
dir, err = os.MkdirTemp("", "gosec")
|
_, err := os.MkdirTemp(dir, "test*.go")
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
|
||||||
_, err = os.MkdirTemp(dir, "test*.go")
|
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
|
||||||
})
|
|
||||||
AfterEach(func() {
|
|
||||||
err := os.RemoveAll(dir)
|
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
It("should return the root directory as package path", func() {
|
It("should return the root directory as package path", func() {
|
||||||
|
|
Loading…
Reference in a new issue