fix(provider): detect source code drift and validate package/function references

This commit is contained in:
Naeel
2026-04-15 10:51:40 +03:00
parent e2b6a4472e
commit 1b8bff8364
6 changed files with 252 additions and 0 deletions
@@ -2,7 +2,9 @@ package resources
import (
"context"
"crypto/sha256"
"encoding/base64"
"fmt"
"os"
"path/filepath"
"testing"
@@ -113,6 +115,16 @@ func TestResolveNamespace(t *testing.T) {
}
}
func TestCalculateCodeHash(t *testing.T) {
input := []byte("def main():\n return 'ok'\n")
got := calculateCodeHash(input)
expected := fmt.Sprintf("%x", sha256.Sum256(input))
if got != expected {
t.Fatalf("unexpected code hash: got %q want %q", got, expected)
}
}
func TestUnstructuredToPackageModelSetsNullComputed(t *testing.T) {
obj := &unstructured.Unstructured{Object: map[string]interface{}{
"apiVersion": "fission.io/v1",