github.com/FusionAuth/go-client@v0.0.0-20240425220342-2317e10dfcf5/pkg/fusionauth/Client_test.go (about)

     1  /*
     2   * Copyright (c) 2020, FusionAuth, All Rights Reserved
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *   http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing,
    11   * software distributed under the License is distributed on an
    12   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
    13   * either express or implied. See the License for the specific
    14   * language governing permissions and limitations under the License.
    15   */
    16  package fusionauth
    17  
    18  import (
    19  	"net/http"
    20  	"net/url"
    21  	"os"
    22  	"testing"
    23  	"time"
    24  
    25  	"github.com/stretchr/testify/assert"
    26  )
    27  
    28  const (
    29  	host string = "http://localhost:9011"
    30  )
    31  
    32  var (
    33  	httpClient = &http.Client{
    34  		Timeout: time.Second * 10,
    35  	}
    36  	baseURL, _ = url.Parse(host)
    37  )
    38  
    39  var faClient = NewClient(httpClient, baseURL, "af69486b-4733-4470-a592-f1bfce7af580")
    40  
    41  func TestRetrieveUser(t *testing.T) {
    42  	userResponse, _, _ := faClient.RetrieveUser("missing@example.com")
    43  	assert.Equal(t, 401, userResponse.StatusCode)
    44  }
    45  
    46  func TestMain(m *testing.M) {
    47  	os.Exit(m.Run())
    48  }