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
words = ["B$u$i$ld", "$t$$h$e", "N$e$x$t", "E$$ra", "$$o$f$", "S$$of$t$wa$r$e", "De$$ve$l$op$me$n$t"] | |
i = words.size - 1 | |
result = '' | |
while i >= 0 | |
s = i == 0 ? '' : ' ' | |
word = words[i] | |
result = result + word.gsub('$', '').upcase + s | |
i = i-1 |
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
// internal/user/delivery_test.go | |
package user | |
import ( | |
"bytes" | |
"context" | |
"net/http" | |
"net/http/httptest" | |
reflect "reflect" | |
"strings" |
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
package user | |
import ( | |
"context" | |
"encoding/json" | |
"net/http" | |
) | |
type userDelivery struct { | |
registerUserUseCase RegisterUserUseCase |
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
// internal/user/delivery.go | |
package user | |
import ( | |
"context" | |
"fmt" | |
"reflect" | |
"testing" | |
"github.com/golang/mock/gomock" |
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
// Code generated by MockGen. DO NOT EDIT. | |
// Source: internal/user/repo.go | |
// Package user is a generated GoMock package. | |
package user | |
import ( | |
context "context" | |
reflect "reflect" |
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
#!/bin/bash | |
mockgen -source=internal/user/repo.go \ | |
-destination=internal/user/repo_mock_test.go \ | |
-package=user \ | |
-self_package=github.com/syafdia/demo-unit-test/internal/user |
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
// internal/user/usecase.go | |
package user | |
import "context" | |
type RegisterUserUseCase interface { | |
Execute(ctx context.Context, input CreateUserInput) (User, error) | |
} | |
type registerUserUseCase struct { |
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
// internal/user/repo_test.go | |
package user | |
import ( | |
"context" | |
"errors" | |
"reflect" | |
"regexp" | |
"testing" |
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
// internal/user/repo.go | |
package user | |
import ( | |
"context" | |
"github.com/jmoiron/sqlx" | |
) | |
type UserRepo interface { |
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
// calc_test.go | |
package calc | |
import "testing" | |
func TestFactorial(t *testing.T) { | |
type args struct { | |
n uint | |
} | |
tests := []struct { |
NewerOlder