| 
									
										
										
										
											2018-11-23 09:00:30 +00:00
										 |  |  | // Copyright 2018 Mikhail Klementev. All rights reserved. | 
					
						
							|  |  |  | // Use of this source code is governed by a AGPLv3 license | 
					
						
							|  |  |  | // (or later) that can be found in the LICENSE file. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package config | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-18 16:07:24 +00:00
										 |  |  | 	"code.dumpstack.io/tools/out-of-tree/distro" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-23 09:00:30 +00:00
										 |  |  | 	"github.com/naoina/toml" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func TestMarshalUnmarshal(t *testing.T) { | 
					
						
							|  |  |  | 	artifactCfg := Artifact{ | 
					
						
							|  |  |  | 		Name: "Put name here", | 
					
						
							|  |  |  | 		Type: KernelModule, | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-05-18 18:13:09 +00:00
										 |  |  | 	artifactCfg.Targets = append(artifactCfg.Targets, | 
					
						
							| 
									
										
										
										
											2023-05-18 18:48:09 +00:00
										 |  |  | 		Target{ | 
					
						
							|  |  |  | 			Distro: distro.Distro{ | 
					
						
							|  |  |  | 				ID:      distro.Ubuntu, | 
					
						
							|  |  |  | 				Release: "18.04", | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			Kernel: Kernel{ | 
					
						
							|  |  |  | 				Regex: ".*", | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2018-11-23 09:00:30 +00:00
										 |  |  | 	buf, err := toml.Marshal(&artifactCfg) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		t.Fatal(err) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var artifactCfgNew Artifact | 
					
						
							|  |  |  | 	err = toml.Unmarshal(buf, &artifactCfgNew) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		t.Fatal(err) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |