fcmtest

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fcmtest is a fake FCM endpoint for tests (HTTP v1 sends and Instance ID subscriptions): it records what it receives and answers by rules on the target.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TokenSource

func TokenSource() oauth2.TokenSource

TokenSource is a static token for the fake.

Types

type Answer

type Answer struct {
	Status     int
	Code       string
	Message    string
	RetryAfter string
	// Times: answer this many times, then accept; 0: always.
	Times int
}

Answer is how the server responds to a token or topic.

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is the fake.

func Start

func Start(t *testing.T) *Server

Start runs a fake for the test.

func (*Server) Answer

func (s *Server) Answer(target string, a Answer)

Answer sets how target (a token, or "topic:<name>") is answered.

func (*Server) Auth

func (s *Server) Auth() []string

Auth are the Authorization headers seen.

func (*Server) Received

func (s *Server) Received() []map[string]any

Received are the accepted messages' "message" objects.

func (*Server) Subscribed

func (s *Server) Subscribed(topic string) []string

Subscribed are the tokens subscribed to topic.

Jump to

Keyboard shortcuts

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