mock

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mock provides an in-memory mock Datastore server for testing.

This package can be used by both ds9 internal tests and by end-users who want to test their code that depends on ds9 without hitting real Datastore APIs.

Example usage:

import "github.com/codeGROOVE-dev/ds9/pkg/datastore"

func TestMyCode(t *testing.T) {
    client, cleanup := datastore.NewMockClient(t)
    defer cleanup()

    // Use client in your tests
    key := datastore.NameKey("Task", "task-1", nil)
    _, err := client.Put(ctx, key, &myTask)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockServers

func NewMockServers(t *testing.T) (metadataURL, apiURL string, cleanup func())

NewMockServers creates mock metadata and API servers for testing. Returns the metadata URL, API URL, and a cleanup function. This function doesn't import datastore to avoid import cycles.

For convenience, use datastore.NewMockClient() instead which handles all setup.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store holds the in-memory entity storage.

func NewStore

func NewStore() *Store

NewStore creates a new in-memory store.

Jump to

Keyboard shortcuts

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