...

Source file src/go.mongodb.org/mongo-driver/mongo/integration/unified/options.go

Documentation: go.mongodb.org/mongo-driver/mongo/integration/unified

     1  // Copyright (C) MongoDB, Inc. 2017-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 unified
     8  
     9  var defaultRunKillAllSessionsValue = true
    10  
    11  // Options is the type used to configure tests
    12  type Options struct {
    13  	// Specifies if killAllSessions should be run after the test completes.
    14  	// Defaults to true
    15  	RunKillAllSessions *bool
    16  }
    17  
    18  // NewOptions creates an empty options interface
    19  func NewOptions() *Options {
    20  	return &Options{&defaultRunKillAllSessionsValue}
    21  }
    22  
    23  // SetRunKillAllSessions sets the value for RunKillAllSessions
    24  func (op *Options) SetRunKillAllSessions(killAllSessions bool) *Options {
    25  	op.RunKillAllSessions = &killAllSessions
    26  	return op
    27  }
    28  
    29  // MergeOptions combines the given *Options into a single *Options in a last one wins fashion.
    30  //
    31  // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a
    32  // single options struct instead.
    33  func MergeOptions(opts ...*Options) *Options {
    34  	op := NewOptions()
    35  	for _, opt := range opts {
    36  		if opt == nil {
    37  			continue
    38  		}
    39  		if opt.RunKillAllSessions != nil {
    40  			op.RunKillAllSessions = opt.RunKillAllSessions
    41  		}
    42  	}
    43  
    44  	return op
    45  }
    46  

View as plain text