Skip to content

Commit f5f290a

Browse files
committed
add ci
1 parent bedc9b3 commit f5f290a

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: 1.21
20+
21+
- name: Install dependencies
22+
run: go mod tidy
23+
24+
- name: Run tests
25+
run: go test ./...

config/config_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package config
2+
3+
import (
4+
"flag"
5+
"testing"
6+
)
7+
8+
func TestParseArgsDefault(t *testing.T) {
9+
10+
args := []string{"cmd"}
11+
oldArgs := flag.CommandLine
12+
flag.CommandLine = flag.NewFlagSet(args[0], flag.ExitOnError)
13+
defer func() { flag.CommandLine = oldArgs }()
14+
15+
config := ParseArgs()
16+
17+
if config.Method != "GET" {
18+
t.Errorf("Méthode par défaut incorrecte: attendu GET, obtenu %s", config.Method)
19+
}
20+
}

0 commit comments

Comments
 (0)