permify

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 5 Imported by: 1

README

![Tests](https://github.com/theoriginalstove/testcontainers-permify/actions/workflows/test.yaml/badge.svg?event=push)

Permify Testcontainer - testcontainers implementation for Permify

Install

Use go get to install the latest version of the library.

go get -u github.com/theoriginalstove/testcontainers-permify@latest

Usage

import (
    "context"
    "testing"

    "github.com/stretchr/testify/require"
	permifygrpc "github.com/Permify/permify-go/grpc"
    permifytest "github.com/theoriginalstove/testcontainers-permify"
)

func TestPermify(t *testing.T) {
    permifyClient := setupPermify(t)
    // your code here
}

func setupPermify(t *testing.T) *permify_gcpc.Client {
    ctx := context.Background()

    container, err := permifytest.Run(ctx)
    require.NoError(t, err)
    t.Cleanup(func() {
        err := container.Terminate(ctx)
        require.NoError(t, err)
    })

	container, err := Run(ctx)
	require.NoError(t, err)
	t.Cleanup(func() {
		err = container.Terminate(ctx)
		require.NoError(t, err, "failed to terminate container")
	})

	host, err := container.Host(ctx)
	require.NoError(t, err, "failed to fetch permify host")

	grpcPort, err := container.GRPCPort(ctx)
	require.NoError(t, err, "failed to fetch permify grpc api port")

	client, err := permify_grpc.NewClient(permify_grpc.Config{
		Endpoint: fmt.Sprintf("%s:%d", host, grpcPort),
	}, grpc.WithTransportCredentials(insecure.NewCredentials()))
	require.NoError(t, err, "failed to initialize permify grpc clinet")

    return client
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PermifyContainer

type PermifyContainer struct {
	testcontainers.Container
}

PermifyContainer is a wrapper around testcontainers.Container that provides some conveince methods for working with Permify.

func Run

Run creates an instance of the Permify container type.

func (PermifyContainer) GRPCPort

func (p PermifyContainer) GRPCPort(ctx context.Context) (int, error)

GRPCPort returns the port which the GRPC API for Permify is listening on.

Jump to

Keyboard shortcuts

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