Compare commits
2 commits
26b6a2d349
...
52a87a41da
Author | SHA1 | Date | |
---|---|---|---|
Lilian Jónsdóttir | 52a87a41da | ||
Lilian Jónsdóttir | e7a6e395d7 |
|
@ -131,8 +131,9 @@ var (
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "force",
|
Name: "force",
|
||||||
Usage: "re-encrypt the file even if no changes have been made.",
|
Usage: "re-encrypt the file even if no changes have been made",
|
||||||
Aliases: []string{"f"},
|
Aliases: []string{"f"},
|
||||||
|
DisableDefaultText: true,
|
||||||
Action: func(ctx *cli.Context, b bool) error {
|
Action: func(ctx *cli.Context, b bool) error {
|
||||||
force_overwrite = b
|
force_overwrite = b
|
||||||
return nil
|
return nil
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
||||||
module git.burning.moe/celediel/agedit
|
module git.burning.moe/celediel/agedit
|
||||||
|
|
||||||
go 1.21.0
|
go 1.22.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
filippo.io/age v1.1.1
|
filippo.io/age v1.1.1
|
||||||
|
|
|
@ -79,7 +79,7 @@ func TestMultipleIdentities(t *testing.T) {
|
||||||
recipients []age.Recipient
|
recipients []age.Recipient
|
||||||
)
|
)
|
||||||
|
|
||||||
for i := 0; i <= 10; i++ {
|
for range 10 {
|
||||||
id, err := age.GenerateX25519Identity()
|
id, err := age.GenerateX25519Identity()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("age broke: %v", err)
|
t.Fatalf("age broke: %v", err)
|
||||||
|
@ -142,7 +142,7 @@ func TestMultipleIdentities(t *testing.T) {
|
||||||
|
|
||||||
// TestNewIdentity creats a new identity, writes it to file, then re-reads it back from the file.
|
// TestNewIdentity creats a new identity, writes it to file, then re-reads it back from the file.
|
||||||
func TestNewIdentity(t *testing.T) {
|
func TestNewIdentity(t *testing.T) {
|
||||||
for i := 0; i <= 1000; i++ {
|
for range 1000 {
|
||||||
outfile := generator.GenerateFullPath()
|
outfile := generator.GenerateFullPath()
|
||||||
|
|
||||||
identity, err := NewIdentity()
|
identity, err := NewIdentity()
|
||||||
|
|
|
@ -36,7 +36,7 @@ func NewGenerator(prefix, suffix string, length int) Generator {
|
||||||
|
|
||||||
func randomString(set string, length int) string {
|
func randomString(set string, length int) string {
|
||||||
out := strings.Builder{}
|
out := strings.Builder{}
|
||||||
for i := 0; i < length; i++ {
|
for range length {
|
||||||
out.WriteByte(randomChar(set))
|
out.WriteByte(randomChar(set))
|
||||||
}
|
}
|
||||||
return out.String()
|
return out.String()
|
||||||
|
|
|
@ -12,7 +12,7 @@ var generator = NewGenerator("test_", ".txt", 18)
|
||||||
func TestCanCreateTmpFile(t *testing.T) {
|
func TestCanCreateTmpFile(t *testing.T) {
|
||||||
b := []byte{104, 101, 108, 108, 111, 32, 116, 104, 101, 114, 101}
|
b := []byte{104, 101, 108, 108, 111, 32, 116, 104, 101, 114, 101}
|
||||||
|
|
||||||
for i := 0; i <= 1000; i++ {
|
for range 1000 {
|
||||||
outfile := generator.GenerateFullPath()
|
outfile := generator.GenerateFullPath()
|
||||||
err := os.WriteFile(outfile, b, fs.FileMode(0600))
|
err := os.WriteFile(outfile, b, fs.FileMode(0600))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -33,7 +33,7 @@ func TestCanCreateTmpFile(t *testing.T) {
|
||||||
func TestUniqueTmpFile(t *testing.T) {
|
func TestUniqueTmpFile(t *testing.T) {
|
||||||
var generated_names = map[string]string{}
|
var generated_names = map[string]string{}
|
||||||
|
|
||||||
for i := 0; i <= 100000; i++ {
|
for range 100000 {
|
||||||
name := generator.GenerateName()
|
name := generator.GenerateName()
|
||||||
if val, ok := generated_names[name]; ok {
|
if val, ok := generated_names[name]; ok {
|
||||||
t.Fatal("Non unique name", val)
|
t.Fatal("Non unique name", val)
|
||||||
|
|
Loading…
Reference in a new issue