mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Remove optional prod options - use build tags instead
This commit is contained in:
parent
3ac557ccb1
commit
5f2c1f4534
2 changed files with 0 additions and 136 deletions
|
|
@ -20,19 +20,6 @@ type Options struct {
|
|||
|
||||
// PanicHandler is a way to register a custom panic handler
|
||||
PanicHandler func(any)
|
||||
|
||||
// ProductionOverrides allows you to have different options in production builds
|
||||
// We would love if we could merge the options, but we can't because of the way
|
||||
// Go handles zero values.
|
||||
ProductionOverrides *Options
|
||||
}
|
||||
|
||||
func (o Options) getOptions(debugMode bool) Options {
|
||||
if o.ProductionOverrides == nil || debugMode {
|
||||
o.ProductionOverrides = nil
|
||||
return o
|
||||
}
|
||||
return *o.ProductionOverrides
|
||||
}
|
||||
|
||||
// AssetOptions defines the configuration of the AssetServer.
|
||||
|
|
|
|||
|
|
@ -1,123 +0,0 @@
|
|||
package application
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOptions_getOptions(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input Options
|
||||
debugMode bool
|
||||
want Options
|
||||
}{
|
||||
{
|
||||
name: "Override Icon in Production",
|
||||
input: Options{
|
||||
Icon: []byte("debug-icon"),
|
||||
ProductionOverrides: &Options{
|
||||
Icon: []byte("prod-icon"),
|
||||
},
|
||||
},
|
||||
want: Options{
|
||||
Icon: []byte("prod-icon"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Don't override Icon in debug",
|
||||
input: Options{
|
||||
Icon: []byte("debug-icon"),
|
||||
ProductionOverrides: &Options{
|
||||
Icon: []byte("prod-icon"),
|
||||
},
|
||||
},
|
||||
debugMode: true,
|
||||
want: Options{
|
||||
Icon: []byte("debug-icon"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Override Mac in Production",
|
||||
input: Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: false,
|
||||
},
|
||||
ProductionOverrides: &Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
want: Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Don't override Mac in debug",
|
||||
input: Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: false,
|
||||
},
|
||||
ProductionOverrides: &Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
debugMode: true,
|
||||
want: Options{
|
||||
Mac: MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Override Flags in Production",
|
||||
input: Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "debug",
|
||||
},
|
||||
ProductionOverrides: &Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "prod",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "prod",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Do not override Flags in debug",
|
||||
input: Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "debug",
|
||||
},
|
||||
ProductionOverrides: &Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "prod",
|
||||
},
|
||||
},
|
||||
},
|
||||
debugMode: true,
|
||||
want: Options{
|
||||
Flags: map[string]interface{}{
|
||||
"environment": "debug",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := tt.input.getOptions(tt.debugMode); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("getOptions() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue