...

Source file src/github.com/launchdarkly/go-server-sdk/v6/testhelpers/ldtestdata/package_info.go

Documentation: github.com/launchdarkly/go-server-sdk/v6/testhelpers/ldtestdata

     1  // Package ldtestdata provides a mechanism for providing dynamically updatable feature flag state in a
     2  // simplified form to an SDK client in test scenarios. The entry point for using this feature is
     3  // [DataSource].
     4  //
     5  // Unlike the file data source (in the [github.com/launchdarkly/go-server-sdk/v6/ldfiledata] package),
     6  // this mechanism does not use any external resources. It provides only the data that the application
     7  // has put into it using the Update method.
     8  //
     9  //	td := ldtestdata.DataSource()
    10  //	td.Update(td.Flag("flag-key-1").BooleanFlag().VariationForAll(true))
    11  //
    12  //	config := ld.Config{
    13  //		DataSource: td,
    14  //	}
    15  //	client := ld.MakeCustomClient(sdkKey, config, timeout)
    16  //
    17  //	// flags can be updated at any time:
    18  //	td.Update(td.Flag("flag-key-2").
    19  //		VariationForUser("some-user-key", true).
    20  //		FallthroughVariation(false))
    21  //
    22  // The above example uses a simple boolean flag, but more complex configurations are possible using
    23  // the methods of the [FlagBuilder] that is returned by [TestDataSource.Flag]. FlagBuilder supports many of
    24  // the ways a flag can be configured on the LaunchDarkly dashboard, but does not currently support 1.
    25  // rule operators other than "in" and "not in", or 2. percentage rollouts.
    26  //
    27  // If the same TestDataSource instance is used to configure multiple LDClient instances, any change
    28  // made to the data will propagate to all of the LDClients.
    29  package ldtestdata
    30  

View as plain text