testrig

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config) error {
	testrig.InitTestLog()

	c := testrig.NewTestConfig()
	dbService := testrig.NewTestDB()
	testrig.StandardDBSetup(dbService, nil)
	router := testrig.NewTestRouter(dbService)
	storageBackend := testrig.NewTestStorage()
	testrig.StandardStorageSetup(storageBackend, "./testrig/media")

	oauthServer := testrig.NewTestOauthServer(dbService)
	transportController := testrig.NewTestTransportController(testrig.NewMockHTTPClient(func(req *http.Request) (*http.Response, error) {
		r := ioutil.NopCloser(bytes.NewReader([]byte{}))
		return &http.Response{
			StatusCode: 200,
			Body:       r,
		}, nil
	}), dbService)
	federator := testrig.NewTestFederator(dbService, transportController, storageBackend)

	emailSender := testrig.NewEmailSender("./web/template/", nil)

	processor := testrig.NewTestProcessor(dbService, storageBackend, federator, emailSender)
	if err := processor.Start(ctx); err != nil {
		return fmt.Errorf("error starting processor: %s", err)
	}

	idp, err := oidc.NewIDP(ctx, c)
	if err != nil {
		return fmt.Errorf("error creating oidc idp: %s", err)
	}

	authModule := auth.New(c, dbService, oauthServer, idp)
	accountModule := account.New(c, processor)
	instanceModule := instance.New(c, processor)
	appsModule := app.New(c, processor)
	followRequestsModule := followrequest.New(c, processor)
	webfingerModule := webfinger.New(c, processor)
	nodeInfoModule := nodeinfo.New(c, processor)
	webBaseModule := web.New(c, processor)
	usersModule := user.New(c, processor)
	timelineModule := timeline.New(c, processor)
	notificationModule := notification.New(c, processor)
	searchModule := search.New(c, processor)
	filtersModule := filter.New(c, processor)
	emojiModule := emoji.New(c, processor)
	listsModule := list.New(c, processor)
	mm := mediaModule.New(c, processor)
	fileServerModule := fileserver.New(c, processor)
	adminModule := admin.New(c, processor)
	statusModule := status.New(c, processor)
	securityModule := security.New(c, dbService)
	streamingModule := streaming.New(c, processor)
	favouritesModule := favourites.New(c, processor)
	blocksModule := blocks.New(c, processor)
	userClientModule := userClient.New(c, processor)

	apis := []api.ClientModule{

		securityModule,
		authModule,

		webBaseModule,
		accountModule,
		instanceModule,
		appsModule,
		followRequestsModule,
		mm,
		fileServerModule,
		adminModule,
		statusModule,
		webfingerModule,
		nodeInfoModule,
		usersModule,
		timelineModule,
		notificationModule,
		searchModule,
		filtersModule,
		emojiModule,
		listsModule,
		streamingModule,
		favouritesModule,
		blocksModule,
		userClientModule,
	}

	for _, m := range apis {
		if err := m.Route(router); err != nil {
			return fmt.Errorf("routing error: %s", err)
		}
	}

	gts, err := gotosocial.NewServer(dbService, router, federator, c)
	if err != nil {
		return fmt.Errorf("error creating gotosocial service: %s", err)
	}

	if err := gts.Start(ctx); err != nil {
		return fmt.Errorf("error starting gotosocial service: %s", err)
	}

	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
	sig := <-sigs
	logrus.Infof("received signal %s, shutting down", sig)

	testrig.StandardDBTeardown(dbService)
	testrig.StandardStorageTeardown(storageBackend)

	if err := gts.Stop(ctx); err != nil {
		return fmt.Errorf("error closing gotosocial service: %s", err)
	}

	logrus.Info("done! exiting...")
	return nil
}

Start creates and starts a gotosocial testrig server

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL