...

Source file src/google.golang.org/api/internal/gensupport/params_test.go

Documentation: google.golang.org/api/internal/gensupport

     1  // Copyright 2021 Google LLC. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package gensupport
     6  
     7  import (
     8  	"net/http"
     9  	"testing"
    10  
    11  	"google.golang.org/api/googleapi"
    12  )
    13  
    14  func TestSetOptionsGetMulti(t *testing.T) {
    15  	co := googleapi.QueryParameter("key", "foo", "bar")
    16  	urlParams := make(URLParams)
    17  	SetOptions(urlParams, co)
    18  	if got, want := urlParams.Encode(), "key=foo&key=bar"; got != want {
    19  		t.Fatalf("URLParams.Encode() = %q, want %q", got, want)
    20  	}
    21  }
    22  
    23  func TestSetHeaders(t *testing.T) {
    24  	userAgent := "google-api-go-client/123"
    25  	contentType := "application/json"
    26  	userHeaders := make(http.Header)
    27  	userHeaders.Set("baz", "300")
    28  	got := SetHeaders(userAgent, contentType, userHeaders, "foo", "100", "bar", "200")
    29  
    30  	if len(got) != 6 {
    31  		t.Fatalf("SetHeaders() = %q, want len(6)", got)
    32  	}
    33  }
    34  

View as plain text