func TestCreateBuildOptionsMap(t *testing.T) { context := make(map[string]interface{}) context[constants.CTX_BUILD_PATH] = "buildPath" context[constants.CTX_HARDWARE_FOLDERS] = []string{"hardware", "hardware2"} context[constants.CTX_TOOLS_FOLDERS] = []string{"tools"} context[constants.CTX_OTHER_LIBRARIES_FOLDERS] = []string{"libraries"} context[constants.CTX_FQBN] = "fqbn" context[constants.CTX_SKETCH_LOCATION] = "sketchLocation" context[constants.CTX_VERBOSE] = true context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "ideVersion" context[constants.CTX_DEBUG_LEVEL] = 5 create := builder.CreateBuildOptionsMap{} err := create.Run(context) NoError(t, err) buildOptions := context[constants.CTX_BUILD_OPTIONS].(map[string]string) require.Equal(t, 6, len(utils.KeysOfMapOfString(buildOptions))) require.Equal(t, "hardware,hardware2", buildOptions[constants.CTX_HARDWARE_FOLDERS]) require.Equal(t, "tools", buildOptions[constants.CTX_TOOLS_FOLDERS]) require.Equal(t, "libraries", buildOptions[constants.CTX_OTHER_LIBRARIES_FOLDERS]) require.Equal(t, "fqbn", buildOptions[constants.CTX_FQBN]) require.Equal(t, "sketchLocation", buildOptions[constants.CTX_SKETCH_LOCATION]) require.Equal(t, "ideVersion", buildOptions[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION]) require.Equal(t, "{\n"+ " \"fqbn\": \"fqbn\",\n"+ " \"hardwareFolders\": \"hardware,hardware2\",\n"+ " \"otherLibrariesFolders\": \"libraries\",\n"+ " \"runtime.ide.version\": \"ideVersion\",\n"+ " \"sketchLocation\": \"sketchLocation\",\n"+ " \"toolsFolders\": \"tools\"\n"+ "}", context[constants.CTX_BUILD_OPTIONS_JSON].(string)) }
func TestCreateBuildOptionsMap(t *testing.T) { ctx := &types.Context{ HardwareFolders: []string{"hardware", "hardware2"}, ToolsFolders: []string{"tools"}, OtherLibrariesFolders: []string{"libraries"}, SketchLocation: "sketchLocation", FQBN: "fqbn", ArduinoAPIVersion: "ideVersion", Verbose: true, BuildPath: "buildPath", DebugLevel: 5, } create := builder.CreateBuildOptionsMap{} err := create.Run(ctx) NoError(t, err) require.Equal(t, "{\n"+ " \"builtInLibrariesFolders\": \"\",\n"+ " \"customBuildProperties\": \"\",\n"+ " \"fqbn\": \"fqbn\",\n"+ " \"hardwareFolders\": \"hardware,hardware2\",\n"+ " \"otherLibrariesFolders\": \"libraries\",\n"+ " \"runtime.ide.version\": \"ideVersion\",\n"+ " \"sketchLocation\": \"sketchLocation\",\n"+ " \"toolsFolders\": \"tools\"\n"+ "}", ctx.BuildOptionsJson) }