...

Source file src/go.mongodb.org/mongo-driver/mongo/readpref/mode_test.go

Documentation: go.mongodb.org/mongo-driver/mongo/readpref

     1  // Copyright (C) MongoDB, Inc. 2020-present.
     2  
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package readpref
     8  
     9  import (
    10  	"testing"
    11  
    12  	"go.mongodb.org/mongo-driver/internal/assert"
    13  )
    14  
    15  func TestMode_String(t *testing.T) {
    16  	t.Parallel()
    17  
    18  	testCases := []struct {
    19  		name string
    20  		mode Mode
    21  	}{
    22  		{"primary", PrimaryMode},
    23  		{"primaryPreferred", PrimaryPreferredMode},
    24  		{"secondary", SecondaryMode},
    25  		{"secondaryPreferred", SecondaryPreferredMode},
    26  		{"nearest", NearestMode},
    27  		{"unknown", Mode(42)},
    28  	}
    29  
    30  	for _, tc := range testCases {
    31  		t.Run(tc.name, func(t *testing.T) {
    32  			assert.Equal(t, tc.name, tc.mode.String(), "expected %q, got %q", tc.name, tc.mode.String())
    33  		})
    34  	}
    35  }
    36  

View as plain text