Skip to content

Commit 37f9434

Browse files
authored
Merge pull request #2 from pepabo/feature/add-github-actions
Add GitHub Actions workflow for Go tests
2 parents b06d954 + 068f14a commit 37f9434

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Go Test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
name: Test
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: '1.24'
17+
cache: true
18+
19+
- name: Install dependencies
20+
run: go mod download
21+
22+
- name: Run tests
23+
run: go test -v ./...

onelogin/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (o *Onelogin) CreateUser(user models.User) (models.User, error) {
8686
createdUser := models.User{
8787
ID: int32(createdUserMap["id"].(float64)),
8888
Email: createdUserMap["email"].(string),
89+
Username: createdUserMap["username"].(string),
8990
Firstname: createdUserMap["firstname"].(string),
9091
Lastname: createdUserMap["lastname"].(string),
9192
}

onelogin/user_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package onelogin
22

33
import (
4+
"fmt"
45
"strconv"
56
"testing"
67

@@ -173,7 +174,7 @@ func TestCreateUser(t *testing.T) {
173174
Lastname: "User",
174175
},
175176
mockResponse: map[string]interface{}{
176-
"id": 3,
177+
"id": float64(3),
177178
"email": "newuser@example.com",
178179
"username": "newuser",
179180
"firstname": "New",
@@ -196,7 +197,7 @@ func TestCreateUser(t *testing.T) {
196197
Lastname: "User",
197198
},
198199
mockError: assert.AnError,
199-
expectedError: assert.AnError,
200+
expectedError: fmt.Errorf("error creating user: %v", assert.AnError),
200201
},
201202
}
202203

@@ -209,6 +210,11 @@ func TestCreateUser(t *testing.T) {
209210

210211
mockClient.On("CreateUser", tt.inputUser).Return(tt.mockResponse, tt.mockError)
211212

213+
// Add expectation for UpdateUser call in SetUserState
214+
if tt.expectedError == nil {
215+
mockClient.On("UpdateUser", 3, mock.AnythingOfType("models.User")).Return(nil, nil)
216+
}
217+
212218
createdUser, err := o.CreateUser(tt.inputUser)
213219

214220
if tt.expectedError != nil {

0 commit comments

Comments
 (0)