settings.RedactModelName holds the pick ("" for none, read by
pii.Choose), this computer's own like RedactModel, kept by KeepOwn and
by the GUI's settings save. /api/privacy-model returns the chosen
model's status and every model's, and takes {do: pick, model}: picked
while off it is saved for the next On; picked while on it is
downloaded, and once on disk it is saved and the other model stopped.
Remove deletes both. masking runs the picked model.
TestPrivacyModelPick and TestMaskingUsesThePickedModel fail on the old
code (no pick; Privacy Filter always).
Run: go test ./internal/settings ./internal/gui ./internal/masking
./internal/gateway -run 'Mask|Redact|Privacy|PII|Unmasked'
./internal/gwmw at the pushed head.
19 lines
620 B
Go
19 lines
620 B
Go
package masking
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/pii"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// Masking asks the model the user picked; with none picked, Privacy
|
|
// Filter, which was the only one when the model was turned on.
|
|
func TestMaskingUsesThePickedModel(t *testing.T) {
|
|
for name, want := range map[string]string{"": pii.PrivacyFilter, pii.PrivacyFilter: pii.PrivacyFilter, pii.AstrLinkGuard: pii.AstrLinkGuard} {
|
|
if got := picked(settings.Settings{RedactModel: true, RedactModelName: name}).ID(); got != want {
|
|
t.Errorf("picked %q: %s, want %s", name, got, want)
|
|
}
|
|
}
|
|
}
|