Skip to content
Snippets Groups Projects

Add prerequisite for this 401 errors

Merged Tian Gao requested to merge 32-improve_unauthorized_error_message into main
All threads resolved!
@@ -5,7 +5,6 @@ import (
@@ -5,7 +5,6 @@ import (
"net/http/httptest"
"net/http/httptest"
"testing"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-com/create-stage/code-creation/repository-x-ray/internal/deps"
"gitlab.com/gitlab-com/create-stage/code-creation/repository-x-ray/internal/deps"
)
)
@@ -20,13 +19,13 @@ func Test_apiEndpoint(t *testing.T) {
@@ -20,13 +19,13 @@ func Test_apiEndpoint(t *testing.T) {
func TestGitLabCompletions(t *testing.T) {
func TestGitLabCompletions(t *testing.T) {
tests := []struct {
tests := []struct {
name string
name string
status int
status int
resp string
resp string
want []deps.Dependency
want []deps.Dependency
wantErr bool
wantErr bool
expectedErrMsg string
wantErrMsg string
requestCount int
requestCount int
}{
}{
{
{
"success",
"success",
@@ -92,10 +91,9 @@ func TestGitLabCompletions(t *testing.T) {
@@ -92,10 +91,9 @@ func TestGitLabCompletions(t *testing.T) {
got, err := gl.Completions("prompt")
got, err := gl.Completions("prompt")
if tt.wantErr {
if tt.wantErr {
// test error thrown
require.Error(t, err)
require.Error(t, err)
// test error message
// test error message
assert.EqualError(t, err, tt.expectedErrMsg)
require.EqualError(t, err, tt.wantErrMsg)
} else {
} else {
// reports will be generated
// reports will be generated
require.NoError(t, err)
require.NoError(t, err)
Loading