mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	This PR is part of #4767. It contains * a refactoring of validation error messages * adds the ability to send user-activities to distant federated servers Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8792 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Michael Jerger <michael.jerger@meissa-gmbh.de> Co-committed-by: Michael Jerger <michael.jerger@meissa-gmbh.de>
		
			
				
	
	
		
			40 lines
		
	
	
	
		
			897 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			897 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2025 The Forgejo Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package forgefed
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"forgejo.org/modules/validation"
 | 
						|
 | 
						|
	ap "github.com/go-ap/activitypub"
 | 
						|
	"github.com/stretchr/testify/assert"
 | 
						|
)
 | 
						|
 | 
						|
func Test_ForgeUserActivityValidation(t *testing.T) {
 | 
						|
	note := ForgeUserActivityNote{}
 | 
						|
	note.Type = "Note"
 | 
						|
	note.Content = ap.NaturalLanguageValues{
 | 
						|
		{
 | 
						|
			Ref:   ap.NilLangRef,
 | 
						|
			Value: ap.Content("Any Content!"),
 | 
						|
		},
 | 
						|
	}
 | 
						|
	note.URL = ap.IRI("example.org/user-id/57")
 | 
						|
 | 
						|
	sut := ForgeUserActivity{}
 | 
						|
	sut.Type = "Create"
 | 
						|
	sut.Actor = ap.IRI("example.org/user-id/23")
 | 
						|
	sut.CC = ap.ItemCollection{
 | 
						|
		ap.IRI("example.org/registration/public#2nd"),
 | 
						|
	}
 | 
						|
	sut.To = ap.ItemCollection{
 | 
						|
		ap.IRI("example.org/registration/public"),
 | 
						|
	}
 | 
						|
 | 
						|
	sut.Note = note
 | 
						|
 | 
						|
	valid, _ := validation.IsValid(sut)
 | 
						|
	assert.True(t, valid, "sut expected to be valid: %v\n", sut.Validate())
 | 
						|
}
 |