forked from zyedidia/eget
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d612022
commit 347277d
Showing
2 changed files
with
87 additions
and
30 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,57 @@ | ||
package detectors_test | ||
|
||
import ( | ||
"regexp" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/permafrost-dev/eget/lib/detectors" | ||
) | ||
|
||
var _ = Describe("OS", func() { | ||
var ( | ||
osDarwin OS | ||
osWindows OS | ||
osLinux OS | ||
) | ||
|
||
BeforeEach(func() { | ||
osDarwin = OS{ | ||
Name: "darwin", | ||
Regex: regexp.MustCompile(`(?i)(darwin|mac.?(os)?|osx)`), | ||
} | ||
osWindows = OS{ | ||
Name: "windows", | ||
Regex: regexp.MustCompile(`(?i)([^r]win|windows)`), | ||
} | ||
osLinux = OS{ | ||
Name: "linux", | ||
Regex: regexp.MustCompile(`(?i)(linux|ubuntu)`), | ||
Anti: regexp.MustCompile(`(?i)(android)`), | ||
Priority: regexp.MustCompile(`\.appimage$`), | ||
} | ||
}) | ||
|
||
Describe("Match", func() { | ||
Context("with an OS that matches the given string", func() { | ||
It("should return true for a matching OS string", func() { | ||
Expect(osDarwin.Match("macOS")).To(Equal(true)) | ||
Expect(osWindows.Match("windows10")).To(Equal(true)) | ||
}) | ||
|
||
It("should return false for a non-matching OS string", func() { | ||
Expect(osDarwin.Match("linux")).To(BeFalse()) | ||
Expect(osWindows.Match("darwin")).To(BeFalse()) | ||
}) | ||
|
||
It("should respect anti-patterns", func() { | ||
Expect(osLinux.Match("android")).To(BeFalse()) | ||
}) | ||
|
||
It("should detect priority matches", func() { | ||
_, priority := osLinux.Match("app.appimage") | ||
Expect(priority).To(BeTrue()) | ||
}) | ||
}) | ||
}) | ||
}) |