mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Add regression test for PluginManager.SaveManifest
This commit is contained in:
		
							parent
							
								
									fba80cf6f9
								
							
						
					
					
						commit
						13c1c2815f
					
				@ -519,7 +519,7 @@ namespace Emby.Server.Implementations.Plugins
 | 
				
			|||||||
            return _plugins.Remove(plugin);
 | 
					            return _plugins.Remove(plugin);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private LocalPlugin LoadManifest(string dir)
 | 
					        internal LocalPlugin LoadManifest(string dir)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Version? version;
 | 
					            Version? version;
 | 
				
			||||||
            PluginManifest? manifest = null;
 | 
					            PluginManifest? manifest = null;
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using Emby.Server.Implementations.Plugins;
 | 
				
			||||||
 | 
					using MediaBrowser.Common.Plugins;
 | 
				
			||||||
 | 
					using Microsoft.Extensions.Logging.Abstractions;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Jellyfin.Server.Implementations.Tests.Plugins
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class PluginManagerTests
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private static readonly string _testPathRoot = Path.Combine(Path.GetTempPath(), "jellyfin-test-data");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void SaveManifest_RoundTrip_Success()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var pluginManager = new PluginManager(new NullLogger<PluginManager>(), null!, null!, null!, new Version(1, 0));
 | 
				
			||||||
 | 
					            var manifest = new PluginManifest()
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Version = "1.0"
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var tempPath = Path.Combine(_testPathRoot, "manifest-" + Path.GetRandomFileName());
 | 
				
			||||||
 | 
					            Directory.CreateDirectory(tempPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Assert.True(pluginManager.SaveManifest(manifest, tempPath));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var res = pluginManager.LoadManifest(tempPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Category, res.Manifest.Category);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Changelog, res.Manifest.Changelog);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Description, res.Manifest.Description);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Id, res.Manifest.Id);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Name, res.Manifest.Name);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Overview, res.Manifest.Overview);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Owner, res.Manifest.Owner);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.TargetAbi, res.Manifest.TargetAbi);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Timestamp, res.Manifest.Timestamp);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Version, res.Manifest.Version);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.Status, res.Manifest.Status);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.AutoUpdate, res.Manifest.AutoUpdate);
 | 
				
			||||||
 | 
					            Assert.Equal(manifest.ImagePath, res.Manifest.ImagePath);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user