github.com/sacloud/iaas-api-go@v1.12.0/error_test.go (about)

     1  // Copyright 2022-2023 The sacloud/iaas-api-go Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package iaas
    16  
    17  import (
    18  	"errors"
    19  	"testing"
    20  )
    21  
    22  func TestNoResultsError(t *testing.T) {
    23  	cases := []struct {
    24  		in     error
    25  		expect bool
    26  	}{
    27  		{
    28  			in:     nil,
    29  			expect: false,
    30  		},
    31  		{
    32  			in:     errors.New("foo"),
    33  			expect: false,
    34  		},
    35  		{
    36  			in:     NewNoResultsError(),
    37  			expect: true,
    38  		},
    39  	}
    40  
    41  	for _, tc := range cases {
    42  		got := IsNoResultsError(tc.in)
    43  		if got != tc.expect {
    44  			t.Errorf("got unexpected value: expected: %t got: %t", tc.expect, got)
    45  		}
    46  	}
    47  }