app: add test for a greeting message
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* provide app greeting using a function * test that the app greets properly * run tests for nix with 'nix-shell --run'...
This commit is contained in:
parent
bc1542012b
commit
c05fc6c995
193
.drone.starlark
193
.drone.starlark
|
@ -69,33 +69,20 @@ def main(ctx):
|
|||
},
|
||||
{
|
||||
"name": "nixpkgs-fmt",
|
||||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"pull": "if-not-exists",
|
||||
"image": "docker.io/immawanderer/nix-nixpkgs-fmt:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull nix"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nix",
|
||||
"path": "/nix"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"nix-env -iA nixpkgs.nixpkgs-fmt",
|
||||
"nixpkgs-fmt --version || true",
|
||||
"nixpkgs-fmt --check . || (echo 'run `nixpkgs-fmt .` to fix it' && exit 1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "statix",
|
||||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"image": "docker.io/immawanderer/nix-statix:linux-amd64",
|
||||
"pull": "if-not-exists",
|
||||
"depends_on": ["enable sandbox"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nixconf",
|
||||
"path": "/etc/nix"
|
||||
}
|
||||
],
|
||||
"depends_on": ["enable flakes"],
|
||||
"commands": [
|
||||
"nix-channel --update && nix-env -iA nixpkgs.statix",
|
||||
"statix --version",
|
||||
"statix check ."
|
||||
]
|
||||
|
@ -105,7 +92,7 @@ def main(ctx):
|
|||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"pull": "if-not-exists",
|
||||
# "depends_on": ["nixpkgs-fmt", "statix"],
|
||||
"depends_on": ["nixpkgs-fmt"],
|
||||
"depends_on": ["nixpkgs-fmt", "statix", "enable sandbox"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nixconf",
|
||||
|
@ -113,7 +100,6 @@ def main(ctx):
|
|||
}
|
||||
],
|
||||
"commands": [
|
||||
"cat /etc/nix/nix.conf",
|
||||
"NIXPKGS_ALLOW_BROKEN=1 nix flake check --impure"
|
||||
]
|
||||
},
|
||||
|
@ -148,10 +134,10 @@ def main(ctx):
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "pre-build",
|
||||
"name": "go vet",
|
||||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"pull": "if-not-exists",
|
||||
"depends_on": ["nixpkgs-fmt"],
|
||||
"depends_on": ["enable sandbox"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nix",
|
||||
|
@ -160,11 +146,55 @@ def main(ctx):
|
|||
{
|
||||
"name": "nixconf",
|
||||
"path": "/etc/nix"
|
||||
},
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"nix-env -iA nixpkgs.cachix nixpkgs.glibc",
|
||||
"cachix use go-xkcdreader",
|
||||
"nix develop --command go vet ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "go test",
|
||||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"pull": "if-not-exists",
|
||||
# "depends_on": ["nixpkgs-fmt", "statix"],
|
||||
# "depends_on": ["go vet"],
|
||||
"depends_on": ["enable sandbox"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nix",
|
||||
"path": "/nix"
|
||||
},
|
||||
{
|
||||
"name": "nixconf",
|
||||
"path": "/etc/nix"
|
||||
},
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"nix develop --command go test ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pre-build",
|
||||
"image": "docker.io/immawanderer/nix-cachix-glibc",
|
||||
"pull": "if-not-exists",
|
||||
# "depends_on": ["nixpkgs-fmt", "statix"],
|
||||
"depends_on": ["nixpkgs-fmt", "statix", "enable sandbox"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nixconf",
|
||||
"path": "/etc/nix"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"cachix use go-xkcdreader"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -172,7 +202,7 @@ def main(ctx):
|
|||
"image": "docker.io/nixos/nix:2.8.0-amd64",
|
||||
"pull": "if-not-exists",
|
||||
# "depends_on": ["nix flake check", "statix", "pre-build"],
|
||||
"depends_on": ["statix", "pre-build"],
|
||||
"depends_on": ["nix flake check", "pre-build"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "nix",
|
||||
|
@ -184,7 +214,6 @@ def main(ctx):
|
|||
}
|
||||
],
|
||||
"commands": [
|
||||
"cat /etc/nix/nix.conf",
|
||||
"nix build .#go-xkcdreader"
|
||||
]
|
||||
},
|
||||
|
@ -204,7 +233,7 @@ def main(ctx):
|
|||
}
|
||||
],
|
||||
"commands": [
|
||||
"ldd result/bin/go-xkcdreader"
|
||||
"nix develop --command ldd result/bin/go-xkcdreader"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -216,6 +245,10 @@ def main(ctx):
|
|||
{
|
||||
"name": "nixconf",
|
||||
"temp": {}
|
||||
},
|
||||
{
|
||||
"name": "gopath",
|
||||
"temp": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -237,11 +270,56 @@ def main(ctx):
|
|||
"cat /etc/os-release"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "go env",
|
||||
"image": "docker.io/immawanderer/archlinux-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull archlinux"],
|
||||
"commands": [
|
||||
"go env",
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "vet",
|
||||
"image": "docker.io/immawanderer/archlinux-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull archlinux"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go vet ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"image": "docker.io/immawanderer/archlinux-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull archlinux"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go test -cover ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"image": "docker.io/immawanderer/archlinux-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull archlinux"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go version",
|
||||
"gcc --version",
|
||||
|
@ -258,6 +336,12 @@ def main(ctx):
|
|||
"ldd go-xkcdreader"
|
||||
]
|
||||
}
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"temp": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -279,14 +363,59 @@ def main(ctx):
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"name": "go env",
|
||||
"image": "docker.io/immawanderer/fedora-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull fedora"],
|
||||
"commands": [
|
||||
"go env",
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "vet",
|
||||
"image": "docker.io/immawanderer/fedora-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull fedora"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go vet ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"image": "docker.io/immawanderer/fedora-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull fedora"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go test -cover ./..."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build",
|
||||
"image": "docker.io/immawanderer/fedora-go-fyne:linux-amd64",
|
||||
"pull": "always",
|
||||
"depends_on": ["pull fedora"],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/root/go"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
"go version",
|
||||
"gcc --version",
|
||||
"go build ."
|
||||
"go build -v ."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -299,6 +428,12 @@ def main(ctx):
|
|||
"ldd go-xkcdreader"
|
||||
]
|
||||
}
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"temp": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -157,6 +157,7 @@
|
|||
xorg.xinput
|
||||
xorg.libXi
|
||||
xorg.libXxf86vm
|
||||
xorg.xorgserver
|
||||
|
||||
] else [ ]);
|
||||
};
|
||||
|
|
8
main.go
8
main.go
|
@ -7,13 +7,19 @@
|
|||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
const appGreeting = "welcome to go-xkcdreader"
|
||||
|
||||
func main() {
|
||||
a := app.New()
|
||||
w := a.NewWindow("go-xkcd_reader")
|
||||
|
||||
w.SetContent(widget.NewLabel("Hello"))
|
||||
w.SetContent(makeGreeting())
|
||||
|
||||
w.ShowAndRun()
|
||||
|
||||
fmt.Println("Exited")
|
||||
}
|
||||
|
||||
func makeGreeting() *widget.Label {
|
||||
return widget.NewLabel(appGreeting)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGreetingText(t *testing.T) {
|
||||
want := "welcome to go-xkcdreader"
|
||||
got := makeGreeting()
|
||||
if got.Text != want {
|
||||
t.Errorf("Incorrect initial greeting, want: %q, got: %q", want, got.Text)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue