-
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
bbe7f81
commit eb30870
Showing
9 changed files
with
192 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Install raylib-go dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libxxf86vm-dev wayland-protocols libwayland-dev libxkbcommon-dev | ||
go get -v github.com/gen2brain/raylib-go/raylib | ||
- name: Build project | ||
run: | | ||
make build | ||
make build-w | ||
- name: Archive build artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build-artifacts | ||
path: ./dist |
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,33 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libxxf86vm-dev wayland-protocols libwayland-dev libxkbcommon-dev | ||
go get -v github.com/gen2brain/raylib-go/raylib | ||
- name: Run tests | ||
run: | | ||
make test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package qss | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/mcbattirola/qss/pkg/require" | ||
) | ||
|
||
func TestParseConfigFile(t *testing.T) { | ||
tt := []struct { | ||
name string | ||
content string | ||
expected Config | ||
}{ | ||
{ | ||
name: "empty", | ||
content: "", | ||
expected: Config{}, | ||
}, | ||
{ | ||
name: "with values", | ||
content: ` | ||
font-size=24 | ||
show-help=true | ||
save-path=/`, | ||
expected: Config{ | ||
FontSize: 24, | ||
ShowHelp: true, | ||
FilePath: "/", | ||
}, | ||
}, | ||
{ | ||
name: "ignores comments", | ||
content: ` | ||
#font-size=24 | ||
#show-help=true | ||
save-path=/`, | ||
expected: Config{ | ||
FontSize: 0, | ||
ShowHelp: false, | ||
FilePath: "/", | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range tt { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tmpfile, err := os.CreateTemp("", "config") | ||
require.NoError(t, err) | ||
|
||
defer os.Remove(tmpfile.Name()) | ||
|
||
_, err = tmpfile.Write([]byte(tc.content)) | ||
require.NoError(t, err) | ||
|
||
_, err = tmpfile.Seek(0, 0) | ||
require.NoError(t, err) | ||
config := &Config{} | ||
|
||
parseConfigFile(tmpfile, config) | ||
require.Equal(t, &tc.expected, config) | ||
}) | ||
} | ||
} |
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,18 @@ | ||
package require | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func NoError(t *testing.T, err error) { | ||
if err != nil { | ||
t.Fatalf("Expected no error but got error '%s'", err.Error()) | ||
} | ||
} | ||
|
||
func Equal(t *testing.T, expected any, actual any) { | ||
if !reflect.DeepEqual(expected, actual) { | ||
t.Fatalf("Expected %v to be equal to %v, but result is different", expected, actual) | ||
} | ||
} |