Documentation

Overview

    Package mellium facilitates integration testing against clients.

    Because the integration package requires starting an external process this package must build a testing server into the test binary. To enable the server to start the TestMain function must be used in your testing package. This adds a special flag, -mel.serve, which can be passed to the test binary to start the server instead of running the actual tests.

    Unlike most servers that we test against, this custom server uses a very simple protocol for configuration instead of loading a file: On start it receives its configuration encoded as a gob (see https://golang.org/pkg/encoding/gob/) over stdin. The tests also go ahead and start listening for connections and pass the listeners as extra file descriptors to the server command, this makes sure that both sides of the connection know about the listener, its type, its ports, etc. Finally, the server knows about its temporary directory where it can load other files (such as TLS certificates) because it will be started with the working directory set to the temp dir.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func ConfigFile

    func ConfigFile(cfg Config) integration.Option

      ConfigFile is an option that can be used to configure the command. Unlike most packages ConfigFile options, this does not actually write the config to a file.

      func Test

        Test starts another instance of the tests running in server mode and returns a function that runs subtests using t.Run. Multiple calls to the returned function will result in uniquely named subtests. When all subtests have completed, the daemon is stopped.

        func TestMain

        func TestMain(m *testing.M)

          TestMain must be proxied by any tests that use this package. It checks whether the internal -mel.serve flag has been set, and if so launches a server to be tested against instead of running the tests.

          Types

          type Config

          type Config struct {
          	ListenC2S   bool
          	ListenS2S   bool
          	C2SFeatures []xmpp.StreamFeature
          	S2SFeatures []xmpp.StreamFeature
          	LogXML      bool
          }

            Config contains options that can be used to configure the newly started server.