...

Source file src/github.com/go-kivik/kivik/v4/mockdb/method_test.go

Documentation: github.com/go-kivik/kivik/v4/mockdb

     1  // Licensed under the Apache License, Version 2.0 (the "License"); you may not
     2  // use this file except in compliance with the License. You may obtain a copy of
     3  // the License at
     4  //
     5  //  http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Unless required by applicable law or agreed to in writing, software
     8  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     9  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    10  // License for the specific language governing permissions and limitations under
    11  // the License.
    12  
    13  package mockdb
    14  
    15  import (
    16  	"testing"
    17  
    18  	"gitlab.com/flimzy/testy"
    19  )
    20  
    21  type methodTest struct {
    22  	input    expectation
    23  	standard string
    24  	verbose  string
    25  }
    26  
    27  func testMethod(t *testing.T, test methodTest) {
    28  	t.Helper()
    29  	result := test.input.method(false)
    30  	if result != test.standard {
    31  		t.Errorf("Unexpected method(false) output.\nWant: %s\n Got: %s\n", test.standard, result)
    32  	}
    33  	result = test.input.method(true)
    34  	if result != test.verbose {
    35  		t.Errorf("Unexpected method(true) output.\nWant: %s\n Got: %s\n", test.verbose, result)
    36  	}
    37  }
    38  
    39  func TestCloseMethod(t *testing.T) {
    40  	tests := testy.NewTable()
    41  	tests.Add("empty", methodTest{
    42  		input:    &ExpectedClose{},
    43  		standard: "Close()",
    44  		verbose:  "Close()",
    45  	})
    46  	tests.Run(t, testMethod)
    47  }
    48  
    49  func TestDBCloseMethod(t *testing.T) {
    50  	tests := testy.NewTable()
    51  	tests.Add("empty", methodTest{
    52  		input:    &ExpectedDBClose{},
    53  		standard: "DB.Close()",
    54  		verbose:  "DB.Close(ctx)",
    55  	})
    56  	tests.Run(t, testMethod)
    57  }
    58  

View as plain text